module Berp.Base.StdTypes.Function (function, functionClass) where
import Berp.Base.Monad (constantIO)
import Berp.Base.SemanticTypes (Object (..), Procedure)
import Berp.Base.Identity (newIdentity)
import Berp.Base.Attributes (mkAttributes)
import Berp.Base.StdTypes.Dictionary (emptyDictionary)
import Berp.Base.StdTypes.Type (newType)
import Berp.Base.StdTypes.ObjectBase (objectBase)
import Berp.Base.StdTypes.String (string)
function :: Int -> Procedure -> Object
function arity p = constantIO $ do
identity <- newIdentity
dict <- emptyDictionary
return $
Function
{ object_identity = identity
, object_dict = dict
, object_procedure = p
, object_arity = arity
}
functionClass :: Object
functionClass = constantIO $ do
dict <- attributes
newType [string "function", objectBase, dict]
attributes :: IO Object
attributes = mkAttributes []