diff options
| author | Roman Smrž <roman.smrz@seznam.cz> | 2026-04-12 11:39:29 +0200 |
|---|---|---|
| committer | Roman Smrž <roman.smrz@seznam.cz> | 2026-04-12 14:05:29 +0200 |
| commit | 3a6faf446c2e62add01c5d912a533f20e853ac77 (patch) | |
| tree | b700d72535e9b23e8ec2e57c71a52449d3c26b16 /src/Script/Expr.hs | |
| parent | cd2e1323ef62574f0879e789457248c68ee46326 (diff) | |
Type constructors
Diffstat (limited to 'src/Script/Expr.hs')
| -rw-r--r-- | src/Script/Expr.hs | 13 |
1 files changed, 10 insertions, 3 deletions
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 _) = "<incomplte type>" + 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 |