Created
December 8, 2021 20:06
-
-
Save dminuoso/6b9181446eaffac9ceb0771a0e013d3b to your computer and use it in GitHub Desktop.
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 TypeFamilies #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE AllowAmbiguousTypes #-} | |
data Mode = Field | Descr | |
type family Inner mode field where | |
Inner Field f = f | |
Inner Descr f = String | |
data ArgF (f :: Mode) = ArgF | |
{ field1 :: Inner f Char | |
, field2 :: Inner f Int | |
} | |
someArg :: ArgF Field | |
someArg = ArgF | |
{ field1 = 'c' | |
, field2 = 42 } | |
argDescr :: ArgF Descr | |
argDescr = ArgF | |
{ field1 = "Some field 1" | |
, field2 = "Another fancy field" | |
} | |
type Sel f = forall mode. (ArgF mode -> Inner mode f) | |
get :: Sel f -> f | |
get sel = sel someArg | |
fun :: Sel Char -> Char | |
fun sel = get sel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment