Skip to content

Instantly share code, notes, and snippets.

@dminuoso

dminuoso/f.hs Secret

Created December 8, 2021 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dminuoso/28a5b34a92e4dc050313827ed2470ef9 to your computer and use it in GitHub Desktop.
Save dminuoso/28a5b34a92e4dc050313827ed2470ef9 to your computer and use it in GitHub Desktop.
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilyDependencies #-}
import Data.Typeable
data Mode = Field | Descr
newtype Tagged tag a = Tagged { runTagged :: a }
type family Inner mode field = r | r -> mode field where
Inner Field f = Maybe f
Inner Descr f = Tagged f String
data Pair l r = Pair l r
data ArgF (f :: Mode) = ArgF
{ field1 :: Inner f Char
, field2 :: Inner f Char
}
type Sel pat = forall mode. ArgF mode -> Inner mode pat
f :: Sel pat -> IO pat
f sel = undefined
g :: Sel () -> IO tok
g sel = do
f sel
undefined
describe :: forall a pat. (Typeable a, Tagged a String ~ Inner Descr pat) => Sel pat -> TypeRep
describe _ = typeOf (undefined :: a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment