Skip to content

Instantly share code, notes, and snippets.

@edwinb
Created July 15, 2015 17:43
Show Gist options
  • Save edwinb/87ea863eb53b3cd7bbb5 to your computer and use it in GitHub Desktop.
Save edwinb/87ea863eb53b3cd7bbb5 to your computer and use it in GitHub Desktop.
Overenthusiastic erasure
-- This segfaults, due to an erased name being used in the case
-- block generated for the 'j'' binding
foo : Nat -> ((Int, String) -> Nat -> IO a) -> IO a
foo Z k = k (0, "End") Z
foo (S j) k = foo j (\(i', s'), j' => k (i'+1, s') j')
-- This doesn't segfault, since Idris treats the \j' as an ordinary binder
-- rather than a pattern matching one.
foo' : Nat -> ((Int, String) -> Nat -> IO a) -> IO a
foo' Z k = k (0, "End") Z
foo' (S j) k = foo j (\(i', s') => \ j' => k (i'+1, s') j')
main : IO ()
main = foo 1 (\_, _ => putStrLn "End")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment