Skip to content

Instantly share code, notes, and snippets.

@stew
Created May 5, 2014 13:51
Show Gist options
  • Save stew/11537219 to your computer and use it in GitHub Desktop.
Save stew/11537219 to your computer and use it in GitHub Desktop.
module natToBin
data Parity : Nat -> Type where
even : Parity (n + n)
odd : Parity (S (n + n))
parity : (n:Nat) -> Parity n
natToBin : Nat -> List Bool
natToBin Z = Nil
natToBin k with (parity k)
natToBin (j + j) | even = False :: natToBin j
natToBin (S (j + j)) | odd = True :: natToBin j
-- - + Errors (1)
-- `-- foo.idr line 12 col 3:
-- j is not an accessible pattern variable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment