Created
December 8, 2016 03:29
-
-
Save amosr/724c68a9d4173b588b077f8f2361ea58 to your computer and use it in GitHub Desktop.
Map combinator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Map | |
export | |
map : [a b : Data]. (a -> b) -> Stream# a -> Stream# b | |
with letrec | |
unwrap [a : Data] (xx : Tuple1# a) : a = case xx of T1# a -> a | |
map [a b : Data] (f : a -> b) (as : Stream# a) : Stream# b | |
= unwrap (stream_1_1# (\inp out. letrec | |
p1 = pull# inp p2 | |
p2 v = push# out (f v) p3 | |
p3 = drop# inp p1 | |
in p1) as) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment