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

module Funcons.Core.Values.Composite.Tuples.Tuples where

import Funcons.EDSL

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

types :: TypeRelation
types = [(Name, DataTypeMembers)] -> TypeRelation
typeEnvFromList
    [(Name
"tuples",Name -> [TPattern] -> [DataTypeAltt] -> DataTypeMembers
DataTypeMemberss Name
"tuples" [MetaVar -> SeqSortOp -> TPattern
TPSeqVar MetaVar
"T*" SeqSortOp
StarOp] [Name -> [FTerm] -> Maybe [TPattern] -> DataTypeAltt
DataTypeMemberConstructor Name
"tuple" [MetaVar -> FTerm
TVar MetaVar
"T*"] ([TPattern] -> Maybe [TPattern]
forall a. a -> Maybe a
Just [MetaVar -> SeqSortOp -> TPattern
TPSeqVar MetaVar
"T*" SeqSortOp
StarOp])])]

funcons :: FunconLibrary
funcons = [(Name, EvalFunction)] -> FunconLibrary
libFromList
    [(Name
"tuple",StrictFuncon -> EvalFunction
StrictFuncon StrictFuncon
stepTuple),(Name
"tuple-elements",StrictFuncon -> EvalFunction
StrictFuncon StrictFuncon
stepTuple_elements),(Name
"tuple-zip",StrictFuncon -> EvalFunction
StrictFuncon StrictFuncon
stepTuple_zip),(Name
"tuples",StrictFuncon -> EvalFunction
StrictFuncon StrictFuncon
stepTuples)]

tuple_ :: [Funcons] -> Funcons
tuple_ [Funcons]
fargs = Name -> [Funcons] -> Funcons
FApp Name
"tuple" ([Funcons]
fargs)
stepTuple :: StrictFuncon
stepTuple [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 -> SeqSortOp -> VPattern
VPSeqVar MetaVar
"_X1*" 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 (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
117)]),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
112)]),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
108)]),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*"]) Env
env

tuple_elements_ :: [Funcons] -> Funcons
tuple_elements_ [Funcons]
fargs = Name -> [Funcons] -> Funcons
FApp Name
"tuple-elements" ([Funcons]
fargs)
stepTuple_elements :: StrictFuncon
stepTuple_elements [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
"tuple" [VPattern -> FTerm -> VPattern
VPAnnotated (MetaVar -> SeqSortOp -> VPattern
VPSeqVar MetaVar
"V*" SeqSortOp
StarOp) (FTerm -> SeqSortOp -> FTerm
TSortSeq (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

tuple_zip_ :: [Funcons] -> Funcons
tuple_zip_ [Funcons]
fargs = Name -> [Funcons] -> Funcons
FApp Name
"tuple-zip" ([Funcons]
fargs)
stepTuple_zip :: StrictFuncon
stepTuple_zip [Values]
fargs =
    [Rewrite Rewritten] -> [MSOS StepRes] -> Rewrite Rewritten
evalRules [Rewrite Rewritten
rewrite1,Rewrite Rewritten
rewrite2,Rewrite Rewritten
rewrite3,Rewrite Rewritten
rewrite4] []
    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
"tuple" [VPattern -> FTerm -> VPattern
VPAnnotated (MetaVar -> VPattern
VPMetaVar MetaVar
"V1") (Name -> FTerm
TName Name
"values"),VPattern -> FTerm -> VPattern
VPAnnotated (MetaVar -> SeqSortOp -> VPattern
VPSeqVar MetaVar
"V1*" SeqSortOp
StarOp) (FTerm -> SeqSortOp -> FTerm
TSortSeq (Name -> FTerm
TName Name
"values") SeqSortOp
StarOp)],Name -> [VPattern] -> VPattern
PADT Name
"tuple" [VPattern -> FTerm -> VPattern
VPAnnotated (MetaVar -> VPattern
VPMetaVar MetaVar
"V2") (Name -> FTerm
TName Name
"values"),VPattern -> FTerm -> VPattern
VPAnnotated (MetaVar -> SeqSortOp -> VPattern
VPSeqVar MetaVar
"V2*" SeqSortOp
StarOp) (FTerm -> SeqSortOp -> FTerm
TSortSeq (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
"tuple" [MetaVar -> FTerm
TVar MetaVar
"V1",MetaVar -> FTerm
TVar MetaVar
"V2"],Name -> [FTerm] -> FTerm
TApp Name
"tuple-zip" [Name -> [FTerm] -> FTerm
TApp Name
"tuple" [MetaVar -> FTerm
TVar MetaVar
"V1*"],Name -> [FTerm] -> FTerm
TApp Name
"tuple" [MetaVar -> FTerm
TVar MetaVar
"V2*"]]]) 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
"tuple" [],Name -> [VPattern] -> VPattern
PADT Name
"tuple" []] Env
forall k a. Map k a
env
            FTerm -> Env -> Rewrite Rewritten
rewriteTermTo ([FTerm] -> FTerm
TSeq []) 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
"tuple" [VPattern -> FTerm -> VPattern
VPAnnotated (MetaVar -> SeqSortOp -> VPattern
VPSeqVar MetaVar
"V1+" SeqSortOp
PlusOp) (FTerm -> SeqSortOp -> FTerm
TSortSeq (Name -> FTerm
TName Name
"values") SeqSortOp
PlusOp)],Name -> [VPattern] -> VPattern
PADT Name
"tuple" []] Env
forall k a. Map k a
env
            FTerm -> Env -> Rewrite Rewritten
rewriteTermTo ([FTerm] -> FTerm
TSeq []) Env
env
          rewrite4 :: Rewrite Rewritten
rewrite4 = 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
"tuple" [],Name -> [VPattern] -> VPattern
PADT Name
"tuple" [VPattern -> FTerm -> VPattern
VPAnnotated (MetaVar -> SeqSortOp -> VPattern
VPSeqVar MetaVar
"V2+" SeqSortOp
PlusOp) (FTerm -> SeqSortOp -> FTerm
TSortSeq (Name -> FTerm
TName Name
"values") SeqSortOp
PlusOp)]] Env
forall k a. Map k a
env
            FTerm -> Env -> Rewrite Rewritten
rewriteTermTo ([FTerm] -> FTerm
TSeq []) Env
env

tuples_ :: [Funcons] -> Funcons
tuples_ = Name -> [Funcons] -> Funcons
FApp Name
"tuples"
stepTuples :: StrictFuncon
stepTuples [Values]
ts = Name -> StrictFuncon
rewriteType Name
"tuples" [Values]
ts