{-# LANGUAGE GADTs #-}

module TypeMachine.Log (
    TypeMachineLog,

    -- * Common Log messages
    fieldNotInType,
    emptyResultType,
    fieldNotOptional,
    duplicateKey,
    noTypeParameter,

    -- * Formatting
    formatLog,
) where

type TypeMachineLog = String

-- | Format a log message, to be printed to the user
formatLog :: TypeMachineLog -> String
formatLog :: TypeMachineLog -> TypeMachineLog
formatLog = TypeMachineLog -> TypeMachineLog -> TypeMachineLog
forall a. [a] -> [a] -> [a]
(++) TypeMachineLog
"TypeMachine: "

fieldNotInType :: String -> TypeMachineLog
fieldNotInType :: TypeMachineLog -> TypeMachineLog
fieldNotInType TypeMachineLog
f = TypeMachineLog
"Field '" TypeMachineLog -> TypeMachineLog -> TypeMachineLog
forall a. [a] -> [a] -> [a]
++ TypeMachineLog
f TypeMachineLog -> TypeMachineLog -> TypeMachineLog
forall a. [a] -> [a] -> [a]
++ TypeMachineLog
"' not in type."

emptyResultType :: TypeMachineLog
emptyResultType :: TypeMachineLog
emptyResultType = TypeMachineLog
"Result type is empty."

fieldNotOptional :: String -> TypeMachineLog
fieldNotOptional :: TypeMachineLog -> TypeMachineLog
fieldNotOptional TypeMachineLog
f = TypeMachineLog
"Field '" TypeMachineLog -> TypeMachineLog -> TypeMachineLog
forall a. [a] -> [a] -> [a]
++ TypeMachineLog
f TypeMachineLog -> TypeMachineLog -> TypeMachineLog
forall a. [a] -> [a] -> [a]
++ TypeMachineLog
"' is not optional."

noTypeParameter :: TypeMachineLog
noTypeParameter :: TypeMachineLog
noTypeParameter = TypeMachineLog
"There are no type parameters in this type."

duplicateKey :: TypeMachineLog
duplicateKey :: TypeMachineLog
duplicateKey = TypeMachineLog
"Some keys are duplicated."