2009-11-21から1日間の記事一覧

Functor, Applicative, Foldable, Traversalの練習

class Functor f => Applicative f where pure :: a->f a <*> :: f (a->b)->f a->f b class Foldable t where foldr :: (a->b->b)->b->t a->b foldr f b = foldMap (`f` b) foldMap :: Monoid m => (a->m)->t a->m foldMap f = foldr (mappend . f) mempty c…

loopとfix

話とかは気が向いたら書く… decList x = x:if x == 0 then [] else decList (x - 1) fix $ \f x->x:if x == 0 then [] else f (x - 1) \f x->x:if x == 0 then [] else f (x - 1) fix :: (a->a)->a loop :: a (b, d) (c, d)->a b c fix f = f $ fix f loop f…