-
-
Save dminuoso/ea39c159219afcb4ba56fef01307da12 to your computer and use it in GitHub Desktop.
This file contains 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
foo.hs:30:8: error: | |
• Couldn't match type ‘Inner mode f’ with ‘Inner mode f0’ | |
Expected type: ArgF mode -> Inner mode f0 | |
Actual type: ArgF mode -> Inner mode f | |
NB: ‘Inner’ is a non-injective type family | |
The type variable ‘f0’ is ambiguous | |
• In the ambiguity check for ‘doc’ | |
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes | |
In the type signature: doc :: Sel f -> String | |
| | |
30 | doc :: Sel f -> String |
This file contains 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 TypeFamilies #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE RankNTypes #-} | |
data Mode = Field | Descr | |
type family Inner mode field where | |
Inner Field f = f | |
Inner Descr f = String | |
data ArgF (f :: Mode) = ArgF | |
{ field1 :: Inner f Char | |
, field2 :: Inner f Int | |
} | |
someArg :: ArgF Field | |
someArg = ArgF | |
{ field1 = 'c' | |
, field2 = 42 } | |
argDescr :: ArgF Descr | |
argDescr = ArgF | |
{ field1 = "Some field 1" | |
, field2 = "Another fancy field" | |
} | |
type Sel f = forall mode. (ArgF mode -> Inner mode f) | |
doc :: Sel f -> String | |
doc sel = sel argDescr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment