Created
April 21, 2017 14:35
-
-
Save k0001/2ff37a939f85cd6ae4b653060133bc58 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 #-} | |
{-# LANGUAGE TypeInType #-} | |
import Data.Kind | |
import GHC.Exts (Constraint) | |
import GHC.TypeLits (Nat) | |
type family StarMaker k :: Constraint where | |
StarMaker Type = () | |
StarMaker (_ -> x) = StarMaker x | |
a :: StarMaker Type => () | |
a = () | |
b :: StarMaker (Type -> Type) => () | |
b = () | |
c :: StarMaker Nat => () | |
c = () | |
d :: StarMaker (Nat -> Type) => () | |
d = () | |
e :: StarMaker (Type -> Nat) => () | |
e = () | |
-- Example GHCI interaction | |
-- | |
-- @ | |
-- > a | |
-- () | |
-- | |
-- > b | |
-- () | |
-- | |
-- > c | |
-- <interactive>:36:1: error: | |
-- • Could not deduce: StarMaker Nat arising from a use of ‘c’ | |
-- • When instantiating ‘it’, initially inferred to have | |
-- this overly-general type: | |
-- StarMaker Nat => () | |
-- NB: This instantiation can be caused by the monomorphism restriction. | |
-- > d | |
-- () | |
-- | |
-- > e | |
-- <interactive>:38:1: error: | |
-- • Could not deduce: StarMaker Nat arising from a use of ‘e’ | |
-- • When instantiating ‘it’, initially inferred to have | |
-- this overly-general type: | |
-- StarMaker (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