Created
April 1, 2016 01:01
-
-
Save amosr/9d3372fdb3223f56a925e45b8c1a7516 to your computer and use it in GitHub Desktop.
Type families error that I don't understand
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 NoImplicitPrelude #-} | |
{-# LANGUAGE TypeFamilies #-} | |
class Bonkers b where | |
type Bonkers1 b :: * | |
type Bonkers2 b :: * | |
bonkersFrom :: Bonkers1 b -> Bonkers2 b | |
bonkers' :: Bonkers b => Bonkers1 b -> Bonkers2 b | |
bonkers' = bonkersFrom | |
--- Error --- | |
bonkers.hs:10:13: | |
Could not deduce (Bonkers2 b0 ~ Bonkers2 b) | |
from the context (Bonkers b) | |
bound by the type signature for | |
bonkers' :: Bonkers b => Bonkers1 b -> Bonkers2 b | |
at src/Umami/Test.hs:10:13-49 | |
NB: ‘Bonkers2’ is a type function, and may not be injective | |
The type variable ‘b0’ is ambiguous | |
Expected type: Bonkers1 b -> Bonkers2 b | |
Actual type: Bonkers1 b0 -> Bonkers2 b0 | |
In the ambiguity check for: | |
forall b. Bonkers b => Bonkers1 b -> Bonkers2 b | |
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes | |
In the type signature for ‘bonkers'’: | |
bonkers' :: Bonkers b => Bonkers1 b -> Bonkers2 b | |
--- Without type signature --- | |
{-# LANGUAGE NoImplicitPrelude #-} | |
{-# LANGUAGE TypeFamilies #-} | |
class Bonkers b where | |
type Bonkers1 b :: * | |
type Bonkers2 b :: * | |
bonkersFrom :: Bonkers1 b -> Bonkers2 b | |
bonkers' = bonkersFrom | |
--- Error --- | |
bonkers.hs:10:12: | |
No instance for (Bonkers b0) arising from a use of ‘bonkersFrom’ | |
In the expression: bonkersFrom | |
In an equation for ‘bonkers'’: bonkers' = bonkersFrom |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment