From 3a6faf446c2e62add01c5d912a533f20e853ac77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sun, 12 Apr 2026 11:39:29 +0200 Subject: Type constructors --- src/Script/Expr.hs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/Script/Expr.hs') diff --git a/src/Script/Expr.hs b/src/Script/Expr.hs index bc4f9cb..cc37f73 100644 --- a/src/Script/Expr.hs +++ b/src/Script/Expr.hs @@ -253,8 +253,10 @@ newtype TypeVar = TypeVar Text data SomeExprType = forall a. ExprType a => ExprTypePrim (Proxy a) + | forall a. ExprTypeConstr1 a => ExprTypeConstr1 (Proxy a) | ExprTypeVar TypeVar | forall a. ExprType a => ExprTypeFunction (FunctionArguments SomeArgumentType) (Proxy a) + | ExprTypeApp SomeExprType [ SomeExprType ] someExprType :: SomeExpr -> SomeExprType someExprType (SomeExpr expr) = go expr @@ -285,9 +287,14 @@ someExprType (SomeExpr expr) = go expr proxyOfFunctionType _ = Proxy textSomeExprType :: SomeExprType -> Text -textSomeExprType (ExprTypePrim p) = textExprType p -textSomeExprType (ExprTypeVar (TypeVar name)) = name -textSomeExprType (ExprTypeFunction _ r) = "function:" <> textExprType r +textSomeExprType = go [] + where + go _ (ExprTypePrim p) = textExprType p + go (x : _) (ExprTypeConstr1 c) = textExprTypeConstr1 c x + go [] (ExprTypeConstr1 _) = "" + go _ (ExprTypeVar (TypeVar name)) = name + go _ (ExprTypeFunction _ r) = "function:" <> textExprType r + go _ (ExprTypeApp c xs) = go (map textSomeExprType xs) c data AsFunType a = forall b. (a ~ FunctionType b, ExprType b) => IsFunType -- cgit v1.2.3