Created
April 21, 2017 14:53
-
-
Save k0001/d45c06289da08331ebb2395448adfaad 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 FlexibleContexts #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| {-# LANGUAGE TypeInType #-} | |
| {-# LANGUAGE TypeSynonymInstances #-} | |
| import Data.Kind (Type) | |
| import GHC.TypeLits (Nat) | |
| class Starring ka | |
| instance Starring Type | |
| instance Starring kb => Starring (ka -> kb) | |
| a :: Starring Type => () | |
| a = () | |
| b :: Starring (Type -> Type) => () | |
| b = () | |
| c :: Starring Nat => () | |
| c = () | |
| d :: Starring (Nat -> Type) => () | |
| d = () | |
| e :: Starring (Type -> Nat) => () | |
| e = () | |
| -- GHCi: | |
| -- | |
| -- > a | |
| -- () | |
| -- > b | |
| -- () | |
| -- > c | |
| -- <interactive>:25:1: error: | |
| -- • No instance for (Starring Nat) arising from a use of ‘c’ | |
| -- • When instantiating ‘it’, initially inferred to have | |
| -- this overly-general type: | |
| -- Starring Nat => () | |
| -- NB: This instantiation can be caused by the monomorphism restriction. | |
| -- > d | |
| -- () | |
| -- > e | |
| -- <interactive>:27:1: error: | |
| -- • No instance for (Starring Nat) arising from a use of ‘e’ | |
| -- • When instantiating ‘it’, initially inferred to have | |
| -- this overly-general type: | |
| -- Starring (Type -> Nat) => () | |
| -- NB: This instantiation can be caused by the monomorphism restriction. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment