Skip to content

Instantly share code, notes, and snippets.

@kikkupico
kikkupico / TreeMonad.hs
Created February 9, 2022 08:09
Custom Tree Monad
data Lst t = Nil | Head t (Lst t)
instance Functor Lst where
fmap f Nil = Nil
fmap f (Head x xl) = Head (f x) (fmap f xl)
instance Applicative Lst where
pure x = Head x Nil
Nil <*> _ = Nil
_ <*> Nil = Nil