Skip to content

Instantly share code, notes, and snippets.

@joneshf
Created April 21, 2018 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joneshf/a5d6269efd444eee40e6456a7530effb to your computer and use it in GitHub Desktop.
Save joneshf/a5d6269efd444eee40e6456a7530effb to your computer and use it in GitHub Desktop.
codata
module Main where
import Prelude
class Codata --where
data Stream a
= Head a (Codata => Stream a)
from :: Int -> Stream Int
from x = Head x (from (x + 1))
-- mapStream :: forall a b. (a -> b) -> Stream a -> Stream b
mapStream f (Head x xs) = Head (f x) (mapStream f xs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment