{-# LANGUAGE OverloadedStrings #-}

module Funcons.Core.Computations.Normal.GeneratingBuiltin where

import Funcons.EDSL
import Funcons.Operations hiding (Values,tobool,libFromList)

import Data.Set (fromList)

library :: FunconLibrary
library = [(Name, EvalFunction)] -> FunconLibrary
libFromList [ 
        (Name
"initialise-generating", NonStrictFuncon -> EvalFunction
NonStrictFuncon NonStrictFuncon
stepInitialise_generating)
    ]

initialise_generating_ :: Funcons
initialise_generating_ = Name -> Funcons
FName Name
"initialise-generating"
stepInitialise_generating :: NonStrictFuncon
stepInitialise_generating [Funcons]
fargs =
    [Rewrite Rewritten] -> [MSOS StepRes] -> Rewrite Rewritten
evalRules [] [MSOS StepRes
step1]
    where step1 :: MSOS StepRes
step1 = do
            let env :: Map k a
env = Map k a
forall k a. Map k a
emptyEnv
            Env
env <- [Funcons] -> [FPattern] -> Env -> MSOS Env
lifted_fsMatch [Funcons]
fargs [MetaVar -> FPattern
PMetaVar MetaVar
"P"] Env
forall k a. Map k a
env
            Env
env <- Name -> VPattern -> Env -> MSOS Env
getMutPatt Name
"used-atom-set" (VPattern
VPWildCard) Env
env
            Name -> Values -> MSOS ()
putMut Name
"used-atom-set" Values
reserved_atoms
            FTerm -> Env -> MSOS StepRes
stepTermTo (MetaVar -> FTerm
TVar MetaVar
"P") Env
env
          reserved_atoms :: Values
reserved_atoms = ValueSets Values -> Values
forall t. ValueSets (Values t) -> Values t
Set ([Values] -> ValueSets Values
forall a. Ord a => [a] -> Set a
fromList [])