Skip to content

Instantly share code, notes, and snippets.

@rampion
Created January 5, 2016 13:00
Show Gist options
  • Save rampion/704d3b906e937b931793 to your computer and use it in GitHub Desktop.
Save rampion/704d3b906e937b931793 to your computer and use it in GitHub Desktop.
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DataKinds #-}
module Temp where
data A = A1 | A2
data B = B1 | B2
data C (a :: A) (b :: B)where
C1 :: Int -> C a b
C2 :: Char -> C 'A1 b
C3 :: Bool -> C 'A1 'B1
type family ResT (b :: B) where
ResT B1 = C 'A1 'B1
ResT B2 = C 'A2 'B2
data D (b :: B) where
D1 :: ResT 'B1 -> C 'A1 'B1 -> D 'B1
D2 :: ResT b -> C 'A1 b -> D b
intermediate_func1 :: Int -> D 'B1
intermediate_func1 i = D2 (C1 i) (C1 i)
intermediate_func2 :: Int -> D 'B2
intermediate_func2 i = D2 (C1 i) (C1 i)
intermediate_func :: Int -> D (b :: B)
intermediate_func i = D2 (C1 i) (C1 i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment