Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Prelude hiding((.), id)
- import Control.Arrow
- import Control.Category
- newtype Stream a b = Stream { runStream :: [a] -> [b] }
- instance Category Stream where
- id = Stream (id)
- (.) (Stream (f)) (Stream (g)) = Stream (f . g)
- instance Arrow Stream where
- arr f = Stream (map f)
- first (Stream f) = Stream (unzip >>> first f >>> uncurry zip)
- instance ArrowLoop Stream where
- loop (Stream f) = Stream $ \iL ->
- let (oL,sL) = unzip $ f $ zip iL sL in
- oL
- delay x = Stream (x:)
- stream ~(x:xs) = x:stream xs
- mul = arr (uncurry (*))
- facStream = loop (mul >>> (arr id &&& delay 1))
Add Comment
Please, Sign In to add comment