view paper/src/list_monad.hs @ 92:0354d3693324 default tip

Added tag paper_final for changeset 6a12eb22be8c
author Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
date Sun, 01 Mar 2015 13:08:51 +0900
parents 1181b4facaf9
children
line wrap: on
line source

append :: List a -> List a -> List a
append Nil xs          = xs
append (Cons x xs) xss = Cons x (append xs xss)

concat :: List (List a) -> List a
concat Nil         = Nil
concat (Cons x xs) = append x (Main.concat xs)

eta :: a -> List a
eta x = Cons x Nil

mu :: List (List a) -> List a
mu = Main.concat

instance Monad List where
    return x  = eta x
    li >>= f  = mu (fmap f li)