Skip to content

Instantly share code, notes, and snippets.

@sritchie
Created March 24, 2015 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sritchie/e55f726b3624d3d3273b to your computer and use it in GitHub Desktop.
Save sritchie/e55f726b3624d3d3273b to your computer and use it in GitHub Desktop.
data Wrapper
= WrappedInt Integer
| WrappedFloat Float
unpack :: Num a => Wrapper -> a
unpack (WrappedInt x) = x
unpack (WrappedFloat x) = x
@sritchie
Copy link
Author

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