Skip to content

Instantly share code, notes, and snippets.

@lukaszlew
Last active January 19, 2019 16:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukaszlew/e3251f576f66f6bde2c5cb4646851707 to your computer and use it in GitHub Desktop.
Save lukaszlew/e3251f576f66f6bde2c5cb4646851707 to your computer and use it in GitHub Desktop.
Another exposition of Edward's "Closed kinds aren't as closed as you'd think"
{-# language TypeApplications #-}
{-# language TypeFamilies #-}
{-# language FlexibleInstances #-}
{-# language ScopedTypeVariables #-}
data Unit = U
class C (k :: Unit) where
get :: Int
instance C 'U where
get = 0
-- this can be defined already here
standaloneGet :: forall (t :: Unit) . C t => Int
standaloneGet = get @t
-- the problematic 'matchable' type family
type family Succ :: Unit -> Unit
-- Note that this is different:
type family Succ1 (x :: Unit) :: Unit
instance C (f 'U) where
get = 1
results :: [Int]
results = [get @'U, get @(Succ 'U)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment