Skip to content

Instantly share code, notes, and snippets.

@sritchie sritchie/test.hs
Created Mar 24, 2015

Embed
What would you like to do?
data Wrapper
= WrappedInt Integer
| WrappedFloat Float
unpack :: Num a => Wrapper -> a
unpack (WrappedInt x) = x
unpack (WrappedFloat x) = x
@sritchie

This comment has been minimized.

Copy link
Owner Author

commented Mar 24, 2015

I get this error:

Scheme/Eval.hs:51:25: Could not deduce (a ~ Integer) …
    from the context (Num a)
      bound by the type signature for unpack :: Num a => Wrapper -> a
      at /Users/sritchie/code/haskell/scheme/Scheme/Eval.hs:50:11-31
      ‘a’ is a rigid type variable bound by
          the type signature for unpack :: Num a => Wrapper -> a
          at /Users/sritchie/code/haskell/scheme/Scheme/Eval.hs:50:11
    Relevant bindings include
      unpack :: Wrapper -> a
        (bound at /Users/sritchie/code/haskell/scheme/Scheme/Eval.hs:51:1)
    In the expression: x
    In an equation for ‘unpack’: unpack (WrappedInt x) = x
Compilation failed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.