@@ -51,18 +51,22 @@ cons' = S . lazy
52iterate : (a -> a) -> a -> Stream a
52iterate : (a -> a) -> a -> Stream a
53iterate f x = cons' <| \() ->
53iterate f x = cons' <| \() ->
54− (x, map f (iterate f x))
54+ (x, iterate f (f x))
56{-| Create an infinite Stream of xs. -}
56{-| Create an infinite Stream of xs. -}
57repeat : a -> Stream a
57repeat : a -> Stream a
58−repeat x = iterate id x
58+repeat x = let go = cons x <| \() -> go
60{-| Cycle through the elements of the nonempty list (x :: xs) -}
61{-| Cycle through the elements of the nonempty list (x :: xs) -}
61cycle : a -> [a] -> Stream a
62cycle : a -> [a] -> Stream a
62cycle x xs = let cycle' ys = case ys of
63cycle x xs = let cycle' ys = case ys of
63− [] -> cons' <| \() ->
65+ (y :: ys) -> cons y <| \() ->
64− (x, cycle' xs)
68+ (x, cycle' xs)
65− in cycle' []
69+ in go
67{-| Apply a function to every element of a Stream. -}
71{-| Apply a function to every element of a Stream. -}
68map : (a -> b) -> Stream a -> Stream b
72map : (a -> b) -> Stream a -> Stream b