@@ -1,5 +1,4 @@
1−module Trampoline (Trampoline, trampoline)
1+module Trampoline where
4{-| Trampolining loops for unbounded recursion.
3{-| Trampolining loops for unbounded recursion.
5Since most javascript implementations lack tail-call elimination, deeply tail-recursive functions will result in a stack overflow.
4Since most javascript implementations lack tail-call elimination, deeply tail-recursive functions will result in a stack overflow.
@@ -33,10 +32,10 @@ main = asText <| fac 1000000000000
33@docs Trampoline, trampoline
32@docs Trampoline, trampoline
35import Native.Trampoline
34import Native.Trampoline
38{-| A computation that might loop. A trampoline is either the resulting value or a thunk that needs to be run more. -}
36{-| A computation that might loop. A trampoline is either the resulting value or a thunk that needs to be run more. -}
39−data Trampoline a = Trampoline (Either a (() -> Trampoline a))
37+data Trampoline a = Done a
38+ | Continue (() -> Trampoline a)
41{-| Run a trampolining loop in constant space. -}
40{-| Run a trampolining loop in constant space. -}
42trampoline : Trampoline a -> a
41trampoline : Trampoline a -> a