module Funcons.ValueOperations ( execRewrites, evalOperation, IException(..), IE(..), isIn, ) where import Funcons.EDSL (library) import Funcons.Types import Funcons.MSOS import Funcons.Patterns (isIn) import Funcons.Exceptions (IException(..), IE(..)) import Funcons.RunOptions import Funcons.Core.Manual evalOperation :: Funcons -> Either IE [Values] evalOperation :: Funcons -> Either IE [Values] evalOperation Funcons f = case Rewrite Rewritten -> Either IE Rewritten forall a. Rewrite a -> Either IE a execRewrites (Funcons -> Rewrite Rewritten rewriteFuncons Funcons f) of Left IE exc -> IE -> Either IE [Values] forall a b. a -> Either a b Left IE exc Right (ValTerm [Values] vs) -> [Values] -> Either IE [Values] forall a b. b -> Either a b Right [Values] vs Right Rewritten _ -> [Char] -> Either IE [Values] forall a. HasCallStack => [Char] -> a error [Char] "rewriteToTerm: did you provide a value operation?" execRewrites :: Rewrite a -> (Either IE a) execRewrites :: Rewrite a -> Either IE a execRewrites Rewrite a rew = case Either IException a e_exc_rewritten of Left (Funcons _, Funcons _, IE exc) -> IE -> Either IE a forall a b. a -> Either a b Left IE exc Right a r -> a -> Either IE a forall a b. b -> Either a b Right a r where (Either IException a e_exc_rewritten, RewriteState _, RewriteWriterr _) = Rewrite a -> RewriteReader -> RewriteState -> (Either IException a, RewriteState, RewriteWriterr) forall a. Rewrite a -> RewriteReader -> RewriteState -> (Either IException a, RewriteState, RewriteWriterr) runRewrite Rewrite a rew RewriteReader reader RewriteState state reader :: RewriteReader reader = FunconLibrary -> TypeRelation -> RunOptions -> Funcons -> Funcons -> RewriteReader RewriteReader ([FunconLibrary] -> FunconLibrary libUnions [FunconLibrary Funcons.EDSL.library ,FunconLibrary Funcons.Core.Manual.library]) TypeRelation emptyTypeRelation RunOptions defaultRunOptions Funcons forall a. HasCallStack => a undefined Funcons forall a. HasCallStack => a undefined state :: RewriteState state = RewriteState RewriteState