1module ProjectM36.AtomFunction where
4import qualified ProjectM36.Attribute as A
5import qualified Data.HashSet as HS
7foldAtomFuncType :: AtomType -> AtomType -> [AtomType]
8foldAtomFuncType foldType returnType = [RelationAtomType (A.attributesFromList [Attribute "_" foldType]), returnType]
10atomFunctionForName :: AtomFunctionName -> AtomFunctions -> Either RelationalError AtomFunction
11atomFunctionForName funcName funcSet = if HS.null foundFunc then
12 Left $ NoSuchTupleExprFunctionError funcName
14 Right $ head $ HS.toList foundFunc
16 foundFunc = HS.filter (\(AtomFunction name _ _) -> name == funcName) funcSet
18-- | Create a junk named atom function for use with searching for an already existing function in the AtomFunctions HashSet.
19emptyAtomFunction :: AtomFunctionName -> AtomFunction
20emptyAtomFunction name = AtomFunction { atomFuncName = name,
21 atomFuncType = [AnyAtomType, AnyAtomType],
22 atomFuncBody = AtomFunctionBody Nothing (\(x:_) -> x) }
25-- | AtomFunction constructor for compiled-in functions.
26compiledAtomFunction :: AtomFunctionName -> [AtomType] -> AtomFunctionBodyType -> AtomFunction
27compiledAtomFunction name aType body = AtomFunction { atomFuncName = name,
29 atomFuncBody = AtomFunctionBody Nothing body }
31--the atom function really should offer some way to return an error
32evalAtomFunction :: AtomFunction -> [Atom] -> Atom
33evalAtomFunction func args = case atomFuncBody func of
34 (AtomFunctionBody _ f) -> f args
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list