Last active
May 19, 2017 08:00
-
-
Save edsko/92669e7d8de40e2c2aa8b26cfe02ec9d to your computer and use it in GitHub Desktop.
Using defunctionalization to avoid partially applied type synonyms
This file contains 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 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