Created
December 14, 2014 18:23
-
-
Save dima-starosud/d3b85cee6b2605fb135c to your computer and use it in GitHub Desktop.
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 TypeFamilies, GADTs #-} | |
data OfInt (f :: * -> *) where | |
OfInt :: f Int -> OfInt f | |
type family F a where | |
F a = Maybe a | |
runF :: F Int -> OfInt F | |
runF = OfInt {- Error on this line: | |
Couldn't match type ‘F’ with ‘Maybe’ | |
Expected type: F Int -> OfInt F | |
Actual type: Maybe Int -> OfInt Maybe | |
In the expression: OfInt | |
In an equation for ‘runF’: runF = OfInt | |
-} | |
type family G a where | |
G a = Either a Bool | |
runG :: G Int -> OfInt G | |
runG = OfInt {- Error on this line: | |
Couldn't match type ‘Bool’ with ‘Int’ | |
Expected type: G Int -> OfInt G | |
Actual type: Either Int Int -> OfInt (Either Int) | |
In the expression: OfInt | |
In an equation for ‘runG’: runG = OfInt | |
-} | |
newtype D a = D (Either a Bool) | |
runD :: D Int -> OfInt D | |
runD = OfInt {- works perfectly -} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment