{- |
Module      : Language.Egison.Type.Check
Licence     : MIT

This module provides the built-in type environment for Egison programs.
Note: Type checking is now handled by Infer.hs. This module only provides
the built-in type environment.
-}

module Language.Egison.Type.Check
  ( -- * Built-in environment
    builtinEnv
  ) where

import           Language.Egison.IExpr      (stringToVar)
import           Language.Egison.Type.Env
import           Language.Egison.Type.Types

-- | Built-in type environment with primitive functions
builtinEnv :: TypeEnv
builtinEnv :: TypeEnv
builtinEnv = [(Var, TypeScheme)] -> TypeEnv -> TypeEnv
extendEnvMany (((String, TypeScheme) -> (Var, TypeScheme))
-> [(String, TypeScheme)] -> [(Var, TypeScheme)]
forall a b. (a -> b) -> [a] -> [b]
map (\(String
name, TypeScheme
scheme) -> (String -> Var
stringToVar String
name, TypeScheme
scheme)) [(String, TypeScheme)]
builtinTypes) TypeEnv
emptyEnv

-- | Types for built-in functions
-- Only functions defined in Primitives.hs are included here.
-- Functions defined in lib/ are NOT included (they are loaded from files).
builtinTypes :: [(String, TypeScheme)]
builtinTypes :: [(String, TypeScheme)]
builtinTypes = [[(String, TypeScheme)]] -> [(String, TypeScheme)]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
  [ [(String, TypeScheme)]
constantsTypes
  , [(String, TypeScheme)]
primitivesTypes
  , [(String, TypeScheme)]
arithTypes
  , [(String, TypeScheme)]
stringTypes
  , [(String, TypeScheme)]
typeFunctionsTypes
  , [(String, TypeScheme)]
ioTypes
  , [(String, TypeScheme)]
matcherTypes
  , [(String, TypeScheme)]
utilityTypes
  ]
  where
    a :: TyVar
a = String -> TyVar
TyVar String
"a"

    -- | Make a binary operator type (returns Type, not TypeScheme)
    binOpT :: Type -> Type -> Type -> Type
    binOpT :: Type -> Type -> Type -> Type
binOpT Type
t1 Type
t2 Type
t3 = Type -> Type -> Type
TFun Type
t1 (Type -> Type -> Type
TFun Type
t2 Type
t3)

    -- | Make a ternary operator type
    ternOpT :: Type -> Type -> Type -> Type -> Type
    ternOpT :: Type -> Type -> Type -> Type -> Type
ternOpT Type
t1 Type
t2 Type
t3 Type
t4 = Type -> Type -> Type
TFun Type
t1 (Type -> Type -> Type
TFun Type
t2 (Type -> Type -> Type
TFun Type
t3 Type
t4))

    -- | Make a binary operator type scheme (no type variables)
    binOp :: Type -> Type -> Type -> TypeScheme
    binOp :: Type -> Type -> Type -> TypeScheme
binOp Type
t1 Type
t2 Type
t3 = [TyVar] -> [Constraint] -> Type -> TypeScheme
Forall [] [] (Type -> TypeScheme) -> Type -> TypeScheme
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type -> Type
binOpT Type
t1 Type
t2 Type
t3

    -- | Unary operation
    unaryOp :: Type -> Type -> TypeScheme
    unaryOp :: Type -> Type -> TypeScheme
unaryOp Type
t1 Type
t2 = [TyVar] -> [Constraint] -> Type -> TypeScheme
Forall [] [] (Type -> TypeScheme) -> Type -> TypeScheme
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type
TFun Type
t1 Type
t2

    forallA :: Type -> TypeScheme
    forallA :: Type -> TypeScheme
forallA = [TyVar] -> [Constraint] -> Type -> TypeScheme
Forall [TyVar
a] []

    -- | forallA with binary op
    forallABinOp :: Type -> Type -> Type -> TypeScheme
    forallABinOp :: Type -> Type -> Type -> TypeScheme
forallABinOp Type
t1 Type
t2 Type
t3 = [TyVar] -> [Constraint] -> Type -> TypeScheme
Forall [TyVar
a] [] (Type -> TypeScheme) -> Type -> TypeScheme
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type -> Type
binOpT Type
t1 Type
t2 Type
t3

    -- Constants (from Primitives.hs)
    constantsTypes :: [(String, TypeScheme)]
constantsTypes =
      [ (String
"f.pi", [TyVar] -> [Constraint] -> Type -> TypeScheme
Forall [] [] Type
TFloat)
      , (String
"f.e", [TyVar] -> [Constraint] -> Type -> TypeScheme
Forall [] [] Type
TFloat)
      ]

    -- Primitives from Primitives.hs (strictPrimitives and lazyPrimitives)
    primitivesTypes :: [(String, TypeScheme)]
primitivesTypes =
      [ (String
"addSubscript", Type -> Type -> Type -> TypeScheme
binOp Type
TInt Type
TInt Type
TInt)  -- MathExpr operations
      , (String
"addSuperscript", Type -> Type -> Type -> TypeScheme
binOp Type
TInt Type
TInt Type
TInt)  -- MathExpr operations
      , (String
"assert", Type -> Type -> Type -> TypeScheme
binOp Type
TString Type
TBool Type
TBool)
      , (String
"assertEqual", Type -> TypeScheme
forallA (Type -> TypeScheme) -> Type -> TypeScheme
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type -> Type -> Type
ternOpT Type
TString (TyVar -> Type
TVar TyVar
a) (TyVar -> Type
TVar TyVar
a) Type
TBool)
      , (String
"sortWithSign", [TyVar] -> [Constraint] -> Type -> TypeScheme
Forall [] [] (Type -> TypeScheme) -> Type -> TypeScheme
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type
TFun (Type -> Type
TCollection (Type -> Type
TCollection Type
TInt)) ([Type] -> Type
TTuple [Type
TInt, Type -> Type
TCollection Type
TInt]))
      , (String
"updateFunctionArgs", [TyVar] -> [Constraint] -> Type -> TypeScheme
Forall [] [] (Type -> TypeScheme) -> Type -> TypeScheme
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type
TFun Type
TMathExpr (Type -> Type -> Type
TFun (Type -> Type
TCollection Type
TMathExpr) Type
TMathExpr))
      , (String
"tensorShape", Type -> TypeScheme
forallA (Type -> TypeScheme) -> Type -> TypeScheme
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type
TFun (Type -> Type
TTensor (TyVar -> Type
TVar TyVar
a)) (Type -> Type
TCollection Type
TInt))
      , (String
"tensorToList", Type -> TypeScheme
forallA (Type -> TypeScheme) -> Type -> TypeScheme
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type
TFun (Type -> Type
TTensor (TyVar -> Type
TVar TyVar
a)) (Type -> Type
TCollection (TyVar -> Type
TVar TyVar
a)))
      , (String
"dfOrder", Type -> TypeScheme
forallA (Type -> TypeScheme) -> Type -> TypeScheme
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type
TFun (Type -> Type
TTensor (TyVar -> Type
TVar TyVar
a)) Type
TInt)
      ]

    -- Arithmetic operators (from Primitives.Arith.hs)
    -- Note: +, -, *, /, mod, ^, abs, neg, +., -., *., /., sqrt, exp, log, sin, cos, tan, etc.
    -- are defined in lib/ and are NOT included here
    arithTypes :: [(String, TypeScheme)]
arithTypes =
      [ -- Internal base operators
        (String
"i.+", Type -> Type -> Type -> TypeScheme
binOp Type
TInt Type
TInt Type
TInt)
      , (String
"i.-", Type -> Type -> Type -> TypeScheme
binOp Type
TInt Type
TInt Type
TInt)
      , (String
"i.*", Type -> Type -> Type -> TypeScheme
binOp Type
TInt Type
TInt Type
TInt)
      , (String
"i./", Type -> Type -> Type -> TypeScheme
binOp Type
TInt Type
TInt Type
TInt)
      -- Floating point arithmetic
      , (String
"f.+", Type -> Type -> Type -> TypeScheme
binOp Type
TFloat Type
TFloat Type
TFloat)
      , (String
"f.-", Type -> Type -> Type -> TypeScheme
binOp Type
TFloat Type
TFloat Type
TFloat)
      , (String
"f.*", Type -> Type -> Type -> TypeScheme
binOp Type
TFloat Type
TFloat Type
TFloat)
      , (String
"f./", Type -> Type -> Type -> TypeScheme
binOp Type
TFloat Type
TFloat Type
TFloat)
      -- Fraction operations
      , (String
"numerator", Type -> Type -> TypeScheme
unaryOp Type
TInt Type
TInt)
      , (String
"denominator", Type -> Type -> TypeScheme
unaryOp Type
TInt Type
TInt)
      -- MathExpr operations
      , (String
"fromMathExpr", Type -> Type -> TypeScheme
unaryOp Type
TInt (String -> [Type] -> Type
TInductive String
"MathExpr'" []))
      , (String
"toMathExpr'", Type -> Type -> TypeScheme
unaryOp (String -> [Type] -> Type
TInductive String
"MathExpr'" []) Type
TInt)
      , (String
"symbolNormalize", Type -> Type -> TypeScheme
unaryOp Type
TInt Type
TInt)
      -- Integer operations
      , (String
"i.modulo", Type -> Type -> Type -> TypeScheme
binOp Type
TInt Type
TInt Type
TInt)
      , (String
"i.quotient", Type -> Type -> Type -> TypeScheme
binOp Type
TInt Type
TInt Type
TInt)
      , (String
"i.%", Type -> Type -> Type -> TypeScheme
binOp Type
TInt Type
TInt Type
TInt)
      , (String
"i.power", Type -> Type -> Type -> TypeScheme
binOp Type
TInt Type
TInt Type
TInt)
      , (String
"i.abs", Type -> Type -> TypeScheme
unaryOp Type
TInt Type
TInt)
      , (String
"i.neg", Type -> Type -> TypeScheme
unaryOp Type
TInt Type
TInt)
      , (String
"f.abs", Type -> Type -> TypeScheme
unaryOp Type
TFloat Type
TFloat)
      , (String
"f.neg", Type -> Type -> TypeScheme
unaryOp Type
TFloat Type
TFloat)
      -- Comparison operators
      , (String
"=", Type -> Type -> Type -> TypeScheme
forallABinOp (TyVar -> Type
TVar TyVar
a) (TyVar -> Type
TVar TyVar
a) Type
TBool)
      , (String
"<", Type -> Type -> Type -> TypeScheme
forallABinOp (TyVar -> Type
TVar TyVar
a) (TyVar -> Type
TVar TyVar
a) Type
TBool)
      , (String
"<=", Type -> Type -> Type -> TypeScheme
forallABinOp (TyVar -> Type
TVar TyVar
a) (TyVar -> Type
TVar TyVar
a) Type
TBool)
      , (String
">", Type -> Type -> Type -> TypeScheme
forallABinOp (TyVar -> Type
TVar TyVar
a) (TyVar -> Type
TVar TyVar
a) Type
TBool)
      , (String
">=", Type -> Type -> Type -> TypeScheme
forallABinOp (TyVar -> Type
TVar TyVar
a) (TyVar -> Type
TVar TyVar
a) Type
TBool)
      -- Primitive comparison aliases (to avoid type class method conflicts)
      , (String
"i.<", Type -> Type -> Type -> TypeScheme
binOp Type
TInt Type
TInt Type
TBool)
      , (String
"i.<=", Type -> Type -> Type -> TypeScheme
binOp Type
TInt Type
TInt Type
TBool)
      , (String
"i.>", Type -> Type -> Type -> TypeScheme
binOp Type
TInt Type
TInt Type
TBool)
      , (String
"i.>=", Type -> Type -> Type -> TypeScheme
binOp Type
TInt Type
TInt Type
TBool)
      , (String
"f.<", Type -> Type -> Type -> TypeScheme
binOp Type
TFloat Type
TFloat Type
TBool)
      , (String
"f.<=", Type -> Type -> Type -> TypeScheme
binOp Type
TFloat Type
TFloat Type
TBool)
      , (String
"f.>", Type -> Type -> Type -> TypeScheme
binOp Type
TFloat Type
TFloat Type
TBool)
      , (String
"f.>=", Type -> Type -> Type -> TypeScheme
binOp Type
TFloat Type
TFloat Type
TBool)
      -- Rounding functions
      , (String
"round", Type -> Type -> TypeScheme
unaryOp Type
TFloat Type
TInt)
      , (String
"floor", Type -> Type -> TypeScheme
unaryOp Type
TFloat Type
TInt)
      , (String
"ceiling", Type -> Type -> TypeScheme
unaryOp Type
TFloat Type
TInt)
      , (String
"truncate", Type -> Type -> TypeScheme
unaryOp Type
TFloat Type
TInt)
      -- Math functions
      , (String
"f.sqrt", Type -> Type -> TypeScheme
unaryOp Type
TFloat Type
TFloat)
      , (String
"f.sqrt'", Type -> Type -> TypeScheme
unaryOp Type
TFloat Type
TFloat)
      , (String
"f.exp", Type -> Type -> TypeScheme
unaryOp Type
TFloat Type
TFloat)
      , (String
"f.log", Type -> Type -> TypeScheme
unaryOp Type
TFloat Type
TFloat)
      , (String
"f.sin", Type -> Type -> TypeScheme
unaryOp Type
TFloat Type
TFloat)
      , (String
"f.cos", Type -> Type -> TypeScheme
unaryOp Type
TFloat Type
TFloat)
      , (String
"f.tan", Type -> Type -> TypeScheme
unaryOp Type
TFloat Type
TFloat)
      , (String
"f.asin", Type -> Type -> TypeScheme
unaryOp Type
TFloat Type
TFloat)
      , (String
"f.acos", Type -> Type -> TypeScheme
unaryOp Type
TFloat Type
TFloat)
      , (String
"f.atan", Type -> Type -> TypeScheme
unaryOp Type
TFloat Type
TFloat)
      , (String
"f.sinh", Type -> Type -> TypeScheme
unaryOp Type
TFloat Type
TFloat)
      , (String
"f.cosh", Type -> Type -> TypeScheme
unaryOp Type
TFloat Type
TFloat)
      , (String
"f.tanh", Type -> Type -> TypeScheme
unaryOp Type
TFloat Type
TFloat)
      , (String
"f.asinh", Type -> Type -> TypeScheme
unaryOp Type
TFloat Type
TFloat)
      , (String
"f.acosh", Type -> Type -> TypeScheme
unaryOp Type
TFloat Type
TFloat)
      , (String
"f.atanh", Type -> Type -> TypeScheme
unaryOp Type
TFloat Type
TFloat)
      ]


    -- IO functions (from Primitives.IO.hs)
    ioTypes :: [(String, TypeScheme)]
ioTypes =
      [ (String
"return", Type -> TypeScheme
forallA (Type -> TypeScheme) -> Type -> TypeScheme
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type
TFun (TyVar -> Type
TVar TyVar
a) (Type -> Type
TIO (TyVar -> Type
TVar TyVar
a)))
      , (String
"io", Type -> TypeScheme
forallA (Type -> TypeScheme) -> Type -> TypeScheme
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type
TFun (Type -> Type
TIO (TyVar -> Type
TVar TyVar
a)) (TyVar -> Type
TVar TyVar
a))
      -- File operations (Port type)
      , (String
"openInputFile", Type -> Type -> TypeScheme
unaryOp Type
TString (Type -> Type
TIO Type
TPort))
      , (String
"openOutputFile", Type -> Type -> TypeScheme
unaryOp Type
TString (Type -> Type
TIO Type
TPort))
      , (String
"closeInputPort", Type -> Type -> TypeScheme
unaryOp Type
TPort (Type -> Type
TIO ([Type] -> Type
TTuple [])))
      , (String
"closeOutputPort", Type -> Type -> TypeScheme
unaryOp Type
TPort (Type -> Type
TIO ([Type] -> Type
TTuple [])))
      -- Standard input/output
      , (String
"readChar", Type -> Type -> TypeScheme
unaryOp ([Type] -> Type
TTuple []) (Type -> Type
TIO Type
TChar))
      , (String
"readLine", Type -> Type -> TypeScheme
unaryOp ([Type] -> Type
TTuple []) (Type -> Type
TIO Type
TString))
      , (String
"writeChar", Type -> Type -> TypeScheme
unaryOp Type
TChar (Type -> Type
TIO ([Type] -> Type
TTuple [])))
      , (String
"write", Type -> TypeScheme
forallA (Type -> TypeScheme) -> Type -> TypeScheme
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type
TFun (TyVar -> Type
TVar TyVar
a) (Type -> Type
TIO ([Type] -> Type
TTuple [])))
      -- Port-based input/output
      , (String
"readCharFromPort", Type -> Type -> TypeScheme
unaryOp Type
TPort (Type -> Type
TIO Type
TChar))
      , (String
"readLineFromPort", Type -> Type -> TypeScheme
unaryOp Type
TPort (Type -> Type
TIO Type
TString))
      , (String
"writeCharToPort", Type -> Type -> Type -> TypeScheme
binOp Type
TPort Type
TChar (Type -> Type
TIO ([Type] -> Type
TTuple [])))
      , (String
"writeToPort", Type -> TypeScheme
forallA (Type -> TypeScheme) -> Type -> TypeScheme
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type -> Type
binOpT Type
TPort (TyVar -> Type
TVar TyVar
a) (Type -> Type
TIO ([Type] -> Type
TTuple [])))
      -- File operations
      , (String
"readFile", Type -> Type -> TypeScheme
unaryOp Type
TString (Type -> Type
TIO Type
TString))
      -- EOF checking
      , (String
"isEof", Type -> Type -> TypeScheme
unaryOp ([Type] -> Type
TTuple []) (Type -> Type
TIO Type
TBool))
      , (String
"isEofPort", Type -> Type -> TypeScheme
unaryOp Type
TPort (Type -> Type
TIO Type
TBool))
      -- Flushing
      , (String
"flush", Type -> Type -> TypeScheme
unaryOp ([Type] -> Type
TTuple []) (Type -> Type
TIO ([Type] -> Type
TTuple [])))
      , (String
"flushPort", Type -> Type -> TypeScheme
unaryOp Type
TPort (Type -> Type
TIO ([Type] -> Type
TTuple [])))
      -- Random numbers
      , (String
"rand", Type -> Type -> Type -> TypeScheme
binOp Type
TInt Type
TInt (Type -> Type
TIO Type
TInt))
      , (String
"f.rand", Type -> Type -> Type -> TypeScheme
binOp Type
TFloat Type
TFloat (Type -> Type
TIO Type
TFloat))
      -- IORef operations
      , (String
"newIORef", Type -> TypeScheme
forallA (Type -> TypeScheme) -> Type -> TypeScheme
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type
TFun (TyVar -> Type
TVar TyVar
a) (Type -> Type
TIO (Type -> Type
TIORef (TyVar -> Type
TVar TyVar
a))))
      , (String
"writeIORef", Type -> TypeScheme
forallA (Type -> TypeScheme) -> Type -> TypeScheme
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type -> Type
binOpT (Type -> Type
TIORef (TyVar -> Type
TVar TyVar
a)) (TyVar -> Type
TVar TyVar
a) (Type -> Type
TIO ([Type] -> Type
TTuple [])))
      , (String
"readIORef", Type -> TypeScheme
forallA (Type -> TypeScheme) -> Type -> TypeScheme
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type
TFun (Type -> Type
TIORef (TyVar -> Type
TVar TyVar
a)) (Type -> Type
TIO (TyVar -> Type
TVar TyVar
a)))
      -- Process operations
      , (String
"readProcess", [TyVar] -> [Constraint] -> Type -> TypeScheme
Forall [TyVar
a] [] (Type -> TypeScheme) -> Type -> TypeScheme
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type -> Type -> Type
ternOpT Type
TString (Type -> Type
TCollection Type
TString) Type
TString (Type -> Type
TIO Type
TString))
      ]

    -- Type conversion functions (from Primitives.Types.hs)
    typeFunctionsTypes :: [(String, TypeScheme)]
typeFunctionsTypes =
      [ (String
"itof", Type -> Type -> TypeScheme
unaryOp Type
TInt Type
TFloat)
      , (String
"rtof", Type -> Type -> TypeScheme
unaryOp Type
TInt Type
TFloat)
      , (String
"ctoi", Type -> Type -> TypeScheme
unaryOp Type
TChar Type
TInt)
      , (String
"itoc", Type -> Type -> TypeScheme
unaryOp Type
TInt Type
TChar)
      , (String
"isInteger", Type -> TypeScheme
forallA (Type -> TypeScheme) -> Type -> TypeScheme
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type
TFun (TyVar -> Type
TVar TyVar
a) Type
TBool)
      , (String
"isRational", Type -> TypeScheme
forallA (Type -> TypeScheme) -> Type -> TypeScheme
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type
TFun (TyVar -> Type
TVar TyVar
a) Type
TBool)
      ]

    -- Matchers (only primitive matchers defined in Haskell)
    -- Note: integer, bool, char, string, float, list, multiset, set, sortedList, unorderedPair, eq are defined in lib/
    matcherTypes :: [(String, TypeScheme)]
matcherTypes =
      [ (String
"something", Type -> TypeScheme
forallA (Type -> TypeScheme) -> Type -> TypeScheme
forall a b. (a -> b) -> a -> b
$ Type -> Type
TMatcher (TyVar -> Type
TVar TyVar
a))
      ]

    -- String functions (from Primitives.String.hs)
    stringTypes :: [(String, TypeScheme)]
stringTypes =
      [ (String
"pack", [TyVar] -> [Constraint] -> Type -> TypeScheme
Forall [] [] (Type -> TypeScheme) -> Type -> TypeScheme
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type
TFun (Type -> Type
TCollection Type
TChar) Type
TString)
      , (String
"unpack", [TyVar] -> [Constraint] -> Type -> TypeScheme
Forall [] [] (Type -> TypeScheme) -> Type -> TypeScheme
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type
TFun Type
TString (Type -> Type
TCollection Type
TChar))
      , (String
"unconsString", [TyVar] -> [Constraint] -> Type -> TypeScheme
Forall [] [] (Type -> TypeScheme) -> Type -> TypeScheme
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type
TFun Type
TString ([Type] -> Type
TTuple [Type
TChar, Type
TString]))
      , (String
"lengthString", Type -> Type -> TypeScheme
unaryOp Type
TString Type
TInt)
      , (String
"appendString", Type -> Type -> Type -> TypeScheme
binOp Type
TString Type
TString Type
TString)
      , (String
"splitString", Type -> Type -> Type -> TypeScheme
binOp Type
TString Type
TString (Type -> Type
TCollection Type
TString))
      , (String
"regex", Type -> Type -> Type -> TypeScheme
binOp Type
TString Type
TString (Type -> Type
TCollection ([Type] -> Type
TTuple [Type
TString, Type
TString, Type
TString])))
      , (String
"regexCg", Type -> Type -> Type -> TypeScheme
binOp Type
TString Type
TString (Type -> Type
TCollection ([Type] -> Type
TTuple [Type
TString, Type -> Type
TCollection Type
TString, Type
TString])))
      , (String
"read", [TyVar] -> [Constraint] -> Type -> TypeScheme
Forall [] [] (Type -> Type
TIO Type
TString))
      , (String
"readTsv", Type -> Type -> TypeScheme
unaryOp Type
TString (TyVar -> Type
TVar TyVar
a))
      , (String
"show", Type -> TypeScheme
forallA (Type -> TypeScheme) -> Type -> TypeScheme
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type
TFun (TyVar -> Type
TVar TyVar
a) Type
TString)
      , (String
"showTsv", Type -> TypeScheme
forallA (Type -> TypeScheme) -> Type -> TypeScheme
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type
TFun (TyVar -> Type
TVar TyVar
a) Type
TString)
      ]

    -- Utility functions (from Primitives.hs)
    -- Note: assert and assertEqual are already in primitivesTypes
    -- Note: isInteger and isRational are already in typeFunctionsTypes
    utilityTypes :: [(String, TypeScheme)]
utilityTypes =
      [ -- Boolean constructors
        (String
"True", [TyVar] -> [Constraint] -> Type -> TypeScheme
Forall [] [] Type
TBool)
      , (String
"False", [TyVar] -> [Constraint] -> Type -> TypeScheme
Forall [] [] Type
TBool)
      -- Note: Ordering constructors (Less, Equal, Greater), Maybe constructors (Nothing, Just),
      -- and other algebraicDataMatcher constructors are now automatically registered
      -- when the matcher is defined via registerAlgebraicConstructors
      ]