|
|
|
|
|
by jjaredsimpson
3842 days ago
|
|
newtype HeadList a = HeadList { getHeadList :: [a] }
instance Monad HeadList where
return a = HeadList [a]
m >>= f = HeadList $ fmap (head . getHeadList . f) (getHeadList m)
This is a list instance that only keeps the head of function result, so it's basically just a map.But you could imagine putting any function that returns one result. min max avg normalize, etc |
|