Skip to content

Instantly share code, notes, and snippets.

View sirlensalot's full-sized avatar

Stuart Popejoy sirlensalot

View GitHub Profile
@sirlensalot
sirlensalot / ComonadTree.hs
Created February 25, 2016 04:44
Tree is a comonad
λ> import Data.Tree
λ> import Control.Comonad
λ> let t = Node (1::Int) [Node 2 [Node 4 [],Node 5 []],Node 3 [Node 6 [],Node 7 []]]
λ> let draw = putStrLn . drawTree . fmap show
λ> draw t
1
|
+- 2
| |
| +- 4
@sirlensalot
sirlensalot / TxClassy.hs
Last active January 6, 2016 22:43
Transforming classy stuff.
-- Transforming between classy stuff.
-- | Foo is present in input and output.
data Foo = Foo
-- | Classy.
class HasFoo a where foo :: Lens' a Foo
-- | Maybe Bar is added to output type.
data Bar = Bar