{-# LANGUAGE DataKinds, GADTs #-} data Typ = TInt | TInteger | TUnk deriving Show data SType a where STInt :: SType 'TInt STInteger :: SType 'TInteger STUnk :: SType 'TUnk data Some f where Some :: f a -> Some d data Expr a = Expr (SType a) parse :: String -> Maybe (Some Expr) parse "3" = Just (Some (Expr STInt)) parse "()" = Just (Some (Expr STUnk)) parse _ = Nothing main = pure ()