Skip to content

Instantly share code, notes, and snippets.

@xenophobia
Created May 21, 2013 03:46
Show Gist options
  • Select an option

  • Save xenophobia/5617358 to your computer and use it in GitHub Desktop.

Select an option

Save xenophobia/5617358 to your computer and use it in GitHub Desktop.
import Prelude hiding (head, tail)
import Control.Comonad
data Stream a = St {head :: a, tail :: Stream a}
instance Functor Stream where
fmap f s = St (f (head s)) (fmap f (tail s))
instance Comonad Stream where
extract = head
extend f s = St (f s) (extend f (tail s))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment