List Monad
instance Monad [] where
-- return :: a -> [a]
return x = [x]
-- (>>=) :: [a] -> (a -> [b]) -> [b]
m >>= f = [y | x <- m, y <- f x]mitosis :: String -> [String] -- we will represent cells with simple strings
mitosis = replicate 2
ghci> ["Cell"] >>= mitosis
["Cell", "Cell"]ghci> ["Cell"] >>= mitosis >>= mitosis >>= mitosis
["Cell", "Cell", "Cell", "Cell", "Cell", "Cell", "Cell", "Cell"]Last updated