Skip to content

Instantly share code, notes, and snippets.

@edsko
Last active May 19, 2017 08:00
Show Gist options
  • Save edsko/92669e7d8de40e2c2aa8b26cfe02ec9d to your computer and use it in GitHub Desktop.
Save edsko/92669e7d8de40e2c2aa8b26cfe02ec9d to your computer and use it in GitHub Desktop.
Using defunctionalization to avoid partially applied type synonyms
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE PolyKinds #-}
data Fn a = Id | Const a
type family Apply (fn :: Fn k) (a :: k) :: k where
Apply Id a = a
Apply (Const b) a = b
type Schema f = (Apply f Bool, Apply f Int)
type Example1 = Schema Id -- Example1 ~ (Bool, Int)
type Example2 = Schema (Const Double) -- Example2 ~ (Double, Double)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment