[Haskell-cafe] Type-level numbers problem

Konstantine Rybnikov k-bx at k-bx.com
Mon Aug 18 19:15:42 UTC 2014


Hi!

I wrote one thing with type-level numbers that were represented as simple

data Zero
data Succ a

Then, in order to not invent my own peano numbers, I decided to go look for
ones, and found GHC.TypeLits. But unfortunately, it shows a weird error for
me.

Here is a piece of code: https://gist.github.com/k-bx/a7b49165399658f87358

The one that's below "main" is working properly, while the one on top of it
gives this error:

typenats.hs:17:16:
    No instance for (Op D (0 + 1)) arising from a use of `f'
    Possible fix: add an instance declaration for (Op D (0 + 1))
    In the expression: f (VJ i :: VJ D (0 + 1))
    In an equation for `f': f (VJ i) = f (VJ i :: VJ D (0 + 1))
    In the instance declaration for `Op D 0'

Maybe I worked too much on type-level numbers today to not understand this
simple error I'm getting, but could someone be so kind and explain me what
am I doing wrong?

Thank you very much!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140818/e40ea407/attachment.html>


More information about the Haskell-Cafe mailing list