Last active
June 2, 2019 03:28
-
-
Save greatBigDot/5fb2171f2f9968bc619178d6d1cac066 to your computer and use it in GitHub Desktop.
Inferred type is invalid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE AllowAmbiguousTypes, MultiParamTypeClasses, NoMonomorphismRestriction #-} | |
| module InvalidInference where | |
| class Foo s t where | |
| foo :: t | |
| -- When commented, GHCi infers this type; when uncommented, it yields a type error: | |
| -- bar :: Foo s t => t | |
| bar = foo | |
| {- | |
| Here's the error in question: | |
| InvalidInference.hs:10:7: error: | |
| • Could not deduce (Foo s0 t) arising from a use of ‘foo’ | |
| from the context: Foo s t | |
| bound by the type signature for: | |
| bar :: forall s t. Foo s t => t | |
| at InvalidInference.hs:9:1-19 | |
| The type variable ‘s0’ is ambiguous | |
| Relevant bindings include bar :: t (bound at InvalidInference.hs:10:1) | |
| • In the expression: foo | |
| In an equation for ‘bar’: bar = foo | |
| | | |
| 10 | bar = foo | |
| | ^^^ | |
| Failed, no modules loaded. | |
| -} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment