From 0cbbe31c5f16df73dcc3a73b37cac4a72948f3a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Thu, 27 Aug 2026 20:34:57 +0200 Subject: Accept various builtin types in type expressions --- src/Script/Expr.hs | 5 ++++- src/Script/Expr/Class.hs | 14 +++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'src/Script') diff --git a/src/Script/Expr.hs b/src/Script/Expr.hs index 09b7c80..e6f945d 100644 --- a/src/Script/Expr.hs +++ b/src/Script/Expr.hs @@ -8,6 +8,7 @@ module Script.Expr ( FunctionType, DynamicType, ExprType(..), SomeExpr(..), + SomePrimType(..), TypeVar(..), SomeExprType(..), someExprType, textSomeExprType, renameTypeVar, renameVarInType, @@ -293,6 +294,8 @@ instance ExprType DynamicType where data SomeExpr = forall a. ExprType a => SomeExpr (Expr a) +data SomePrimType = forall a. ExprType a => SomePrimType (Proxy a) + newtype TypeVar = TypeVar Text deriving (Eq, Ord) @@ -569,7 +572,7 @@ data Regex = RegexCompiled Text RE.Regex | RegexString Text instance ExprType Regex where - textExprType _ = T.pack "regex" + textExprType _ = T.pack "Regex" textExprValue _ = T.pack "" exprExpansionConvFrom = listToMaybe $ catMaybes diff --git a/src/Script/Expr/Class.hs b/src/Script/Expr/Class.hs index 5bf8a4b..1a6082a 100644 --- a/src/Script/Expr/Class.hs +++ b/src/Script/Expr/Class.hs @@ -57,7 +57,7 @@ instance ExprType () where textExprValue () = "()" instance ExprType Integer where - textExprType _ = T.pack "integer" + textExprType _ = T.pack "Integer" textExprValue x = T.pack (show x) exprExpansionConvTo = listToMaybe $ catMaybes @@ -67,7 +67,7 @@ instance ExprType Integer where exprEnumerator _ = Just $ ExprEnumerator enumFromTo enumFromThenTo instance ExprType Scientific where - textExprType _ = T.pack "number" + textExprType _ = T.pack "Number" textExprValue x = T.pack (show x) exprExpansionConvTo = listToMaybe $ catMaybes @@ -75,16 +75,16 @@ instance ExprType Scientific where ] instance ExprType Bool where - textExprType _ = T.pack "bool" - textExprValue True = T.pack "true" - textExprValue False = T.pack "false" + textExprType _ = T.pack "Bool" + textExprValue True = T.pack "True" + textExprValue False = T.pack "False" instance ExprType Text where - textExprType _ = T.pack "string" + textExprType _ = T.pack "String" textExprValue x = T.pack (show x) instance ExprType Void where - textExprType _ = T.pack "void" + textExprType _ = T.pack "Void" textExprValue _ = T.pack "" instance ExprType a => ExprType [ a ] where -- cgit v1.2.3