module Number where data Number -- fixed width integers instance Eq Number -- class instances instance Ord Number instance Show Number instance Enum Number instance Num Number instance Bounded Number instance Real Number instance Ix Number instance Integral Number
These variants of the standard Prelude functions provide a portable way to read binary files without risking the dreaded CRLF to LF translation performed on DOS and similar systems.
module IOExtensions where readBinaryFile :: FilePath -> IO String writeBinaryFile :: FilePath -> String -> IO () appendBinaryFile :: FilePath -> String -> IO () openBinaryFile :: FilePath -> IOMode -> IO Handle getCh :: IO Char argv :: [String]
module ListUtils where sums, products :: Num a => [a] -> [a] subsequences :: [a] -> [[a]] permutations :: [a] -> [[a]]
This module also defines a class Sequence for listlike type constructors which defines functions to convert from one listlike type to another. Instances for [], List and Maybe are defined.
module Sequence data List a -- abstract instance Eq a => Eq (List a) instance Ord a => Ord (List a) instance Read a => Read (List a) instance Show a => Show (List a) instance Functor List instance Monad List instance MonadZero List instance MonadPlus List instance Sequence List class (Functor m, MonadPlus m) => Sequence m where fromList :: [a] -> m a toList :: m a -> [a] instance Sequence [] instance Sequence List instance Sequence Maybe
module Trace where trace :: String -> a -> aWhen called, trace prints the string in its first argument, and then returns the second argument as its result. The trace function is not referentially transparent, and should only be used for debugging, or for monitoring execution. You should also be warned that, unless you understand some of the details about the way that Hugs programs are executed, results obtained using trace can be rather confusing. For example, the messages may not appear in the order that you expect. Even ignoring the output that they produce, adding calls to trace can change the semantics of your program. Consider this a warning!
module Interact where type Interact = String -> String end :: Interact readChar, peekChar :: Interact -> (Char -> Interact) -> Interact pressAnyKey :: Interact -> Interact unreadChar :: Char -> Interact -> Interact writeChar :: Char -> Interact -> Interact writeStr :: String -> Interact -> Interact ringBell :: Interact -> Interact readLine :: String -> (String -> Interact) -> InteractAn expression e of type Interact can be executed as a program by evaluating run e.
module AnsiScreen where type Pos = (Int,Int) at :: Pos -> String -> String highlight :: String -> String goto :: Int -> Int -> String home :: String cls :: StringThe definitions in this module will need to be adapted to work with terminals that do not support ANSI escape sequences.
module AnsiInteract(module AnsiInteract, module Interact, module AnsiScreen) where import AnsiScreen import Interact clearScreen :: Interact -> Interact writeAt :: Pos -> String -> Interact -> Interact moveTo :: Pos -> Interact -> Interact readAt :: Pos -> -- start coords Int -> -- max input length (String -> Interact) -> -- continuation Interact defReadAt :: Pos -> -- start coords Int -> -- max input length String -> -- default value (String -> Interact) -> -- continuation Interact promptReadAt :: Pos -> -- start coords Int -> -- max input length String -> -- prompt (String -> Interact) -> -- continuation Interact defPromptReadAt :: Pos -> -- start coords Int -> -- max input length String -> -- prompt String -> -- default value (String -> Interact) -> -- continuation Interact