-- GeNeRaTeD fOr: ../../CBS-beta/Funcons-beta/Values/Composite/Trees/Trees.cbs
{-# LANGUAGE OverloadedStrings #-}

module Funcons.Core.Values.Composite.Trees.Trees where

import Funcons.EDSL

import Funcons.Operations hiding (Values,libFromList)
entities :: [a]
entities = []

types :: TypeRelation
types = [(Name, DataTypeMembers)] -> TypeRelation
typeEnvFromList
    [(Name
"trees",Name -> [TPattern] -> [DataTypeAltt] -> DataTypeMembers
DataTypeMemberss Name
"trees" [MetaVar -> TPattern
TPVar MetaVar
"T"] [Name -> [FTerm] -> Maybe [TPattern] -> DataTypeAltt
DataTypeMemberConstructor Name
"tree" [MetaVar -> FTerm
TVar MetaVar
"T",FTerm -> SeqSortOp -> FTerm
TSortSeq (Name -> [FTerm] -> FTerm
TApp Name
"trees" [MetaVar -> FTerm
TVar MetaVar
"T"]) SeqSortOp
StarOp] ([TPattern] -> Maybe [TPattern]
forall a. a -> Maybe a
Just [MetaVar -> TPattern
TPVar MetaVar
"T"])])]

funcons :: FunconLibrary
funcons = [(Name, EvalFunction)] -> FunconLibrary
libFromList
    [(Name
"tree",StrictFuncon -> EvalFunction
StrictFuncon StrictFuncon
stepTree),(Name
"tree-root-value",StrictFuncon -> EvalFunction
StrictFuncon StrictFuncon
stepTree_root_value),(Name
"tree-branch-sequence",StrictFuncon -> EvalFunction
StrictFuncon StrictFuncon
stepTree_branch_sequence),(Name
"single-branching-sequence",StrictFuncon -> EvalFunction
StrictFuncon StrictFuncon
stepSingle_branching_sequence),(Name
"forest-root-value-sequence",StrictFuncon -> EvalFunction
StrictFuncon StrictFuncon
stepForest_root_value_sequence),(Name
"forest-branch-sequence",StrictFuncon -> EvalFunction
StrictFuncon StrictFuncon
stepForest_branch_sequence),(Name
"forest-value-sequence",StrictFuncon -> EvalFunction
StrictFuncon StrictFuncon
stepForest_value_sequence),(Name
"trees",StrictFuncon -> EvalFunction
StrictFuncon StrictFuncon
stepTrees)]

tree_ :: [Funcons] -> Funcons
tree_ [Funcons]
fargs = Name -> [Funcons] -> Funcons
FApp Name
"tree" ([Funcons]
fargs)
stepTree :: StrictFuncon
stepTree [Values]
fargs =
    [Rewrite Rewritten] -> [MSOS StepRes] -> Rewrite Rewritten
evalRules [Rewrite Rewritten
rewrite1] []
    where rewrite1 :: Rewrite Rewritten
rewrite1 = do
            let env :: Map k a
env = Map k a
forall k a. Map k a
emptyEnv
            Env
env <- [Values] -> [VPattern] -> Env -> Rewrite Env
vsMatch [Values]
fargs [MetaVar -> VPattern
VPMetaVar MetaVar
"_X1",MetaVar -> SeqSortOp -> VPattern
VPSeqVar MetaVar
"_X2*" SeqSortOp
StarOp] Env
forall k a. Map k a
env
            Env
env <- SideCondition -> Env -> Rewrite Env
sideCondition (FTerm -> FTerm -> SideCondition
SCIsInSort (MetaVar -> FTerm
TVar MetaVar
"_X1") (FTerm -> SeqSortOp -> FTerm
TSortSeq (Name -> FTerm
TName Name
"values") SeqSortOp
QuestionMarkOp)) Env
env
            Env
env <- SideCondition -> Env -> Rewrite Env
sideCondition (FTerm -> FTerm -> SideCondition
SCIsInSort (MetaVar -> FTerm
TVar MetaVar
"_X2*") (FTerm -> SeqSortOp -> FTerm
TSortSeq (FTerm -> SeqSortOp -> FTerm
TSortSeq (Name -> FTerm
TName Name
"values") SeqSortOp
QuestionMarkOp) SeqSortOp
StarOp)) Env
env
            FTerm -> Env -> Rewrite Rewritten
rewriteTermTo (Name -> [FTerm] -> FTerm
TApp Name
"datatype-value" [Funcons -> FTerm
TFuncon (Values -> Funcons
FValue (Name -> [Funcons] -> Values
forall t. Name -> [t] -> Values t
ADTVal Name
"list" [Values -> Funcons
FValue (Name -> [Funcons] -> Values
forall t. Name -> [t] -> Values t
ADTVal Name
"unicode-character" [Values -> Funcons
FValue (Integer -> Values
forall t. Integer -> Values t
Int Integer
116)]),Values -> Funcons
FValue (Name -> [Funcons] -> Values
forall t. Name -> [t] -> Values t
ADTVal Name
"unicode-character" [Values -> Funcons
FValue (Integer -> Values
forall t. Integer -> Values t
Int Integer
114)]),Values -> Funcons
FValue (Name -> [Funcons] -> Values
forall t. Name -> [t] -> Values t
ADTVal Name
"unicode-character" [Values -> Funcons
FValue (Integer -> Values
forall t. Integer -> Values t
Int Integer
101)]),Values -> Funcons
FValue (Name -> [Funcons] -> Values
forall t. Name -> [t] -> Values t
ADTVal Name
"unicode-character" [Values -> Funcons
FValue (Integer -> Values
forall t. Integer -> Values t
Int Integer
101)])])),MetaVar -> FTerm
TVar MetaVar
"_X1",MetaVar -> FTerm
TVar MetaVar
"_X2*"]) Env
env

tree_root_value_ :: [Funcons] -> Funcons
tree_root_value_ [Funcons]
fargs = Name -> [Funcons] -> Funcons
FApp Name
"tree-root-value" ([Funcons]
fargs)
stepTree_root_value :: StrictFuncon
stepTree_root_value [Values]
fargs =
    [Rewrite Rewritten] -> [MSOS StepRes] -> Rewrite Rewritten
evalRules [Rewrite Rewritten
rewrite1] []
    where rewrite1 :: Rewrite Rewritten
rewrite1 = do
            let env :: Map k a
env = Map k a
forall k a. Map k a
emptyEnv
            Env
env <- [Values] -> [VPattern] -> Env -> Rewrite Env
vsMatch [Values]
fargs [Name -> [VPattern] -> VPattern
PADT Name
"tree" [VPattern -> FTerm -> VPattern
VPAnnotated (MetaVar -> VPattern
VPMetaVar MetaVar
"V") (Name -> FTerm
TName Name
"values"),VPattern -> FTerm -> VPattern
VPAnnotated (MetaVar -> SeqSortOp -> VPattern
VPSeqVar MetaVar
"___" SeqSortOp
StarOp) (FTerm -> SeqSortOp -> FTerm
TSortSeq (Name -> [FTerm] -> FTerm
TApp Name
"trees" [Name -> FTerm
TName Name
"values"]) SeqSortOp
StarOp)]] Env
forall k a. Map k a
env
            FTerm -> Env -> Rewrite Rewritten
rewriteTermTo (MetaVar -> FTerm
TVar MetaVar
"V") Env
env

tree_branch_sequence_ :: [Funcons] -> Funcons
tree_branch_sequence_ [Funcons]
fargs = Name -> [Funcons] -> Funcons
FApp Name
"tree-branch-sequence" ([Funcons]
fargs)
stepTree_branch_sequence :: StrictFuncon
stepTree_branch_sequence [Values]
fargs =
    [Rewrite Rewritten] -> [MSOS StepRes] -> Rewrite Rewritten
evalRules [Rewrite Rewritten
rewrite1] []
    where rewrite1 :: Rewrite Rewritten
rewrite1 = do
            let env :: Map k a
env = Map k a
forall k a. Map k a
emptyEnv
            Env
env <- [Values] -> [VPattern] -> Env -> Rewrite Env
vsMatch [Values]
fargs [Name -> [VPattern] -> VPattern
PADT Name
"tree" [VPattern -> FTerm -> VPattern
VPAnnotated VPattern
VPWildCard (Name -> FTerm
TName Name
"values"),VPattern -> FTerm -> VPattern
VPAnnotated (MetaVar -> SeqSortOp -> VPattern
VPSeqVar MetaVar
"B*" SeqSortOp
StarOp) (FTerm -> SeqSortOp -> FTerm
TSortSeq (Name -> [FTerm] -> FTerm
TApp Name
"trees" [Name -> FTerm
TName Name
"values"]) SeqSortOp
StarOp)]] Env
forall k a. Map k a
env
            FTerm -> Env -> Rewrite Rewritten
rewriteTermTo (MetaVar -> FTerm
TVar MetaVar
"B*") Env
env

single_branching_sequence_ :: [Funcons] -> Funcons
single_branching_sequence_ [Funcons]
fargs = Name -> [Funcons] -> Funcons
FApp Name
"single-branching-sequence" ([Funcons]
fargs)
stepSingle_branching_sequence :: StrictFuncon
stepSingle_branching_sequence [Values]
fargs =
    [Rewrite Rewritten] -> [MSOS StepRes] -> Rewrite Rewritten
evalRules [Rewrite Rewritten
rewrite1,Rewrite Rewritten
rewrite2,Rewrite Rewritten
rewrite3] []
    where rewrite1 :: Rewrite Rewritten
rewrite1 = do
            let env :: Map k a
env = Map k a
forall k a. Map k a
emptyEnv
            Env
env <- [Values] -> [VPattern] -> Env -> Rewrite Env
vsMatch [Values]
fargs [Name -> [VPattern] -> VPattern
PADT Name
"tree" [VPattern -> FTerm -> VPattern
VPAnnotated (MetaVar -> VPattern
VPMetaVar MetaVar
"V") (Name -> FTerm
TName Name
"values")]] Env
forall k a. Map k a
env
            FTerm -> Env -> Rewrite Rewritten
rewriteTermTo (MetaVar -> FTerm
TVar MetaVar
"V") Env
env
          rewrite2 :: Rewrite Rewritten
rewrite2 = do
            let env :: Map k a
env = Map k a
forall k a. Map k a
emptyEnv
            Env
env <- [Values] -> [VPattern] -> Env -> Rewrite Env
vsMatch [Values]
fargs [Name -> [VPattern] -> VPattern
PADT Name
"tree" [VPattern -> FTerm -> VPattern
VPAnnotated (MetaVar -> VPattern
VPMetaVar MetaVar
"V") (Name -> FTerm
TName Name
"values"),VPattern -> FTerm -> VPattern
VPAnnotated (MetaVar -> VPattern
VPMetaVar MetaVar
"B") (Name -> [FTerm] -> FTerm
TApp Name
"trees" [Name -> FTerm
TName Name
"values"])]] Env
forall k a. Map k a
env
            FTerm -> Env -> Rewrite Rewritten
rewriteTermTo (Name -> [FTerm] -> FTerm
TApp Name
"left-to-right" [MetaVar -> FTerm
TVar MetaVar
"V",Name -> [FTerm] -> FTerm
TApp Name
"single-branching-sequence" [MetaVar -> FTerm
TVar MetaVar
"B"]]) Env
env
          rewrite3 :: Rewrite Rewritten
rewrite3 = do
            let env :: Map k a
env = Map k a
forall k a. Map k a
emptyEnv
            Env
env <- [Values] -> [VPattern] -> Env -> Rewrite Env
vsMatch [Values]
fargs [Name -> [VPattern] -> VPattern
PADT Name
"tree" [VPattern -> FTerm -> VPattern
VPAnnotated VPattern
VPWildCard (Name -> FTerm
TName Name
"values"),VPattern -> FTerm -> VPattern
VPAnnotated VPattern
VPWildCard (Name -> [FTerm] -> FTerm
TApp Name
"trees" [Name -> FTerm
TName Name
"values"]),VPattern -> FTerm -> VPattern
VPAnnotated (MetaVar -> SeqSortOp -> VPattern
VPSeqVar MetaVar
"___" SeqSortOp
PlusOp) (FTerm -> SeqSortOp -> FTerm
TSortSeq (Name -> [FTerm] -> FTerm
TApp Name
"trees" [Name -> FTerm
TName Name
"values"]) SeqSortOp
PlusOp)]] Env
forall k a. Map k a
env
            FTerm -> Env -> Rewrite Rewritten
rewriteTermTo (Name -> FTerm
TName Name
"fail") Env
env

forest_root_value_sequence_ :: [Funcons] -> Funcons
forest_root_value_sequence_ [Funcons]
fargs = Name -> [Funcons] -> Funcons
FApp Name
"forest-root-value-sequence" ([Funcons]
fargs)
stepForest_root_value_sequence :: StrictFuncon
stepForest_root_value_sequence [Values]
fargs =
    [Rewrite Rewritten] -> [MSOS StepRes] -> Rewrite Rewritten
evalRules [Rewrite Rewritten
rewrite1,Rewrite Rewritten
rewrite2] []
    where rewrite1 :: Rewrite Rewritten
rewrite1 = do
            let env :: Map k a
env = Map k a
forall k a. Map k a
emptyEnv
            Env
env <- [Values] -> [VPattern] -> Env -> Rewrite Env
vsMatch [Values]
fargs [VPattern -> FTerm -> VPattern
VPAnnotated (MetaVar -> VPattern
VPMetaVar MetaVar
"B") (Name -> [FTerm] -> FTerm
TApp Name
"trees" [Name -> FTerm
TName Name
"values"]),VPattern -> FTerm -> VPattern
VPAnnotated (MetaVar -> SeqSortOp -> VPattern
VPSeqVar MetaVar
"B*" SeqSortOp
StarOp) (FTerm -> SeqSortOp -> FTerm
TSortSeq (Name -> [FTerm] -> FTerm
TApp Name
"trees" [Name -> FTerm
TName Name
"values"]) SeqSortOp
StarOp)] Env
forall k a. Map k a
env
            FTerm -> Env -> Rewrite Rewritten
rewriteTermTo ([FTerm] -> FTerm
TSeq [Name -> [FTerm] -> FTerm
TApp Name
"tree-root-value" [MetaVar -> FTerm
TVar MetaVar
"B"],Name -> [FTerm] -> FTerm
TApp Name
"forest-root-value-sequence" [MetaVar -> FTerm
TVar MetaVar
"B*"]]) Env
env
          rewrite2 :: Rewrite Rewritten
rewrite2 = do
            let env :: Map k a
env = Map k a
forall k a. Map k a
emptyEnv
            Env
env <- [Values] -> [VPattern] -> Env -> Rewrite Env
vsMatch [Values]
fargs [] Env
forall k a. Map k a
env
            FTerm -> Env -> Rewrite Rewritten
rewriteTermTo ([FTerm] -> FTerm
TSeq []) Env
env

forest_branch_sequence_ :: [Funcons] -> Funcons
forest_branch_sequence_ [Funcons]
fargs = Name -> [Funcons] -> Funcons
FApp Name
"forest-branch-sequence" ([Funcons]
fargs)
stepForest_branch_sequence :: StrictFuncon
stepForest_branch_sequence [Values]
fargs =
    [Rewrite Rewritten] -> [MSOS StepRes] -> Rewrite Rewritten
evalRules [Rewrite Rewritten
rewrite1,Rewrite Rewritten
rewrite2] []
    where rewrite1 :: Rewrite Rewritten
rewrite1 = do
            let env :: Map k a
env = Map k a
forall k a. Map k a
emptyEnv
            Env
env <- [Values] -> [VPattern] -> Env -> Rewrite Env
vsMatch [Values]
fargs [VPattern -> FTerm -> VPattern
VPAnnotated (MetaVar -> VPattern
VPMetaVar MetaVar
"B") (Name -> [FTerm] -> FTerm
TApp Name
"trees" [Name -> FTerm
TName Name
"values"]),VPattern -> FTerm -> VPattern
VPAnnotated (MetaVar -> SeqSortOp -> VPattern
VPSeqVar MetaVar
"B*" SeqSortOp
StarOp) (FTerm -> SeqSortOp -> FTerm
TSortSeq (Name -> [FTerm] -> FTerm
TApp Name
"trees" [Name -> FTerm
TName Name
"values"]) SeqSortOp
StarOp)] Env
forall k a. Map k a
env
            FTerm -> Env -> Rewrite Rewritten
rewriteTermTo ([FTerm] -> FTerm
TSeq [Name -> [FTerm] -> FTerm
TApp Name
"tree-branch-sequence" [MetaVar -> FTerm
TVar MetaVar
"B"],Name -> [FTerm] -> FTerm
TApp Name
"forest-branch-sequence" [MetaVar -> FTerm
TVar MetaVar
"B*"]]) Env
env
          rewrite2 :: Rewrite Rewritten
rewrite2 = do
            let env :: Map k a
env = Map k a
forall k a. Map k a
emptyEnv
            Env
env <- [Values] -> [VPattern] -> Env -> Rewrite Env
vsMatch [Values]
fargs [] Env
forall k a. Map k a
env
            FTerm -> Env -> Rewrite Rewritten
rewriteTermTo ([FTerm] -> FTerm
TSeq []) Env
env

forest_value_sequence_ :: [Funcons] -> Funcons
forest_value_sequence_ [Funcons]
fargs = Name -> [Funcons] -> Funcons
FApp Name
"forest-value-sequence" ([Funcons]
fargs)
stepForest_value_sequence :: StrictFuncon
stepForest_value_sequence [Values]
fargs =
    [Rewrite Rewritten] -> [MSOS StepRes] -> Rewrite Rewritten
evalRules [Rewrite Rewritten
rewrite1,Rewrite Rewritten
rewrite2] []
    where rewrite1 :: Rewrite Rewritten
rewrite1 = do
            let env :: Map k a
env = Map k a
forall k a. Map k a
emptyEnv
            Env
env <- [Values] -> [VPattern] -> Env -> Rewrite Env
vsMatch [Values]
fargs [Name -> [VPattern] -> VPattern
PADT Name
"tree" [VPattern -> FTerm -> VPattern
VPAnnotated (MetaVar -> VPattern
VPMetaVar MetaVar
"V") (Name -> FTerm
TName Name
"values"),VPattern -> FTerm -> VPattern
VPAnnotated (MetaVar -> SeqSortOp -> VPattern
VPSeqVar MetaVar
"B1*" SeqSortOp
StarOp) (FTerm -> SeqSortOp -> FTerm
TSortSeq (Name -> [FTerm] -> FTerm
TApp Name
"trees" [Name -> FTerm
TName Name
"values"]) SeqSortOp
StarOp)],VPattern -> FTerm -> VPattern
VPAnnotated (MetaVar -> SeqSortOp -> VPattern
VPSeqVar MetaVar
"B2*" SeqSortOp
StarOp) (FTerm -> SeqSortOp -> FTerm
TSortSeq (Name -> [FTerm] -> FTerm
TApp Name
"trees" [Name -> FTerm
TName Name
"values"]) SeqSortOp
StarOp)] Env
forall k a. Map k a
env
            FTerm -> Env -> Rewrite Rewritten
rewriteTermTo ([FTerm] -> FTerm
TSeq [MetaVar -> FTerm
TVar MetaVar
"V",Name -> [FTerm] -> FTerm
TApp Name
"forest-value-sequence" [MetaVar -> FTerm
TVar MetaVar
"B1*"],Name -> [FTerm] -> FTerm
TApp Name
"forest-value-sequence" [MetaVar -> FTerm
TVar MetaVar
"B2*"]]) Env
env
          rewrite2 :: Rewrite Rewritten
rewrite2 = do
            let env :: Map k a
env = Map k a
forall k a. Map k a
emptyEnv
            Env
env <- [Values] -> [VPattern] -> Env -> Rewrite Env
vsMatch [Values]
fargs [] Env
forall k a. Map k a
env
            FTerm -> Env -> Rewrite Rewritten
rewriteTermTo ([FTerm] -> FTerm
TSeq []) Env
env

trees_ :: [Funcons] -> Funcons
trees_ = Name -> [Funcons] -> Funcons
FApp Name
"trees"
stepTrees :: StrictFuncon
stepTrees [Values]
ts = Name -> StrictFuncon
rewriteType Name
"trees" [Values]
ts