Skip to content

Commit

Permalink
fix #357
Browse files Browse the repository at this point in the history
  • Loading branch information
Ingo60 committed May 10, 2018
1 parent ed1d1be commit 1926a5e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/comp/Issue357.fr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{--
As outlined in 'https://github.com/Frege/frege/issues/357 #357',
the compiler decides that 'myFoldM' should be strict, despite the tail call
'Maybe.>>=' returns lazy. This is unfortunate, because the recursion happens
on the stack, instead through a Thunk returned by >>=
-}
module tests.comp.Issue357 where

myFoldM :: (b -> a -> Maybe b) -> b -> [a] -> Maybe b
myFoldM f z (x:xs) = f z x >>= \acc -> myFoldM f acc xs
myFoldM _ z [] = pure z

main = println $ myFoldM (\r _ -> Just $! succ r) 0 [1..5000]

0 comments on commit 1926a5e

Please sign in to comment.