module Example exposing (..) import Lazy example : Lazy.Action Int Int example = \cache0 -> let makeThunkFive : Lazy.Action Int (Lazy.Thunk Int) makeThunkFive = Lazy.lazy <| \() cache -> (Debug.log "delayed computation..." 5, cache) (thunk, cache1) = makeThunkFive cache0 (i, cache2) = Lazy.force thunk cache1 (j, cache3) = Lazy.force thunk cache2 (k, cache4) = Lazy.force thunk cache3 in (i + j + k, cache4) example2 : Lazy.Action Int Int example2 = let five () = Lazy.pure (Debug.log "delayed computation..." 5) in Lazy.lazy five |> Lazy.andThen (\thunk -> Lazy.force thunk |> Lazy.andThen (\i -> Lazy.force thunk |> Lazy.andThen (\j -> Lazy.force thunk |> Lazy.andThen (\k -> Lazy.pure (i + j + k) ))))