Skip to content

Latest commit

 

History

History
37 lines (29 loc) · 1.89 KB

README.md

File metadata and controls

37 lines (29 loc) · 1.89 KB

HaskellSamples

Monads:

f :: a -> m b
f :: a -> Maybe b            -- m = Maybe
f :: a -> [] b               -- m = []
f :: a -> (Either s) b       -- m = Either s
f :: a -> ((,) s) b          -- m = ((,) s)
f :: a -> ((->) e) b         -- m = ((->) e)
f :: a -> (State s) b        -- m = State s
f :: a -> IO b               -- m = IO
class Applicative m => Monad (m :: * -> *) where
    return :: a -> m a
    (>>=) :: m a -> (a -> m b) -> m b
    (>>) :: m a -> m b -> m b
    x >> y = x >>= (\_ -> y)
    fail :: String -> m a
  1. return a >>= k == k a
  2. m >>= return == m
  3. (m >>= k) >>= k' == m >>= (k >>= k') -- m >>= (\x -> k x >>= k')

Courses:

haskell type hierarchy