haskell-course-preludes- Small modules for a Haskell course in which Haskell is taught by implementing Prelude functionality.

Safe HaskellNone




Basic Types

type Int = IntSource

data Bool




Arithmetic arithmetic and comparison

Integer arithmetic and comparison

(+) :: Int -> Int -> IntSource

(-) :: Int -> Int -> IntSource

(*) :: Int -> Int -> IntSource

mod :: Int -> Int -> IntSource

Double arithmetic and comparison

Boolean operators

(||) :: Bool -> Bool -> Bool

Boolean "or"

(&&) :: Bool -> Bool -> Bool

Boolean "and"

not :: Bool -> Bool

Boolean "not"

Type conversion functions

Very basic lists

get :: Int -> BasicList a -> aSource

String operations

(<>) :: String -> String -> StringSource

Append two strings.

Other convenient operators

(.) :: (b -> c) -> (a -> b) -> a -> c

Function composition.

trace :: String -> a -> a

The trace function outputs the trace message given as its first argument, before returning the second argument as its result.

For example, this returns the value of f x but first outputs the message.

 trace ("calling f with x = " ++ show x) (f x)

The trace function should only be used for debugging, or for monitoring execution. The function is not referentially transparent: its type indicates that it is a pure function but it has the side effect of outputting the trace message.

error :: [Char] -> a

error stops execution and displays an error message.


print :: Show a => a -> IO ()

The print function outputs a value of any printable type to the standard output device. Printable types are those that are instances of class Show; print converts values to strings for output using the show operation and adds a newline.

For example, a program to print the first 20 integers and their powers of 2 could be written as:

 main = print ([(n, 2^n) | n <- [0..19]])

Ignore these

(>>) :: Monad m => forall a b. m a -> m b -> m b

Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in imperative languages.

return :: Monad m => forall a. a -> m a

Inject a value into the monadic type.