Skip to content

Instantly share code, notes, and snippets.

@k0001
Created April 21, 2017 14:53
Show Gist options
  • Select an option

  • Save k0001/d45c06289da08331ebb2395448adfaad to your computer and use it in GitHub Desktop.

Select an option

Save k0001/d45c06289da08331ebb2395448adfaad to your computer and use it in GitHub Desktop.
{-# 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