-- GeNeRaTeD fOr: ../../CBS/Funcons/Values/Composite values/Algebraic datatype values/variants.aterm {-# LANGUAGE OverloadedStrings #-} module Funcons.Core.Values.CompositeValues.AlgebraicDatatypeValues.Variants where import Funcons.EDSL entities = [] types = typeEnvFromList [("variants",DataTypeMembers [(Nothing,TApp "maps" (TTuple [TName "values",TName "types"]))] [DataTypeConstructor "variant" (TTuple [TName "values",TName "values"])])] funcons = libFromList [("variant-tag",StrictFuncon stepVariant_tag),("variant-value",StrictFuncon stepVariant_value),("variants",StrictFuncon stepVariants),("variant",StrictFuncon stepVariant)] -- | -- /variants(M)/ is the type of tagged values /variant(K,V)/ where /V/ . -- /variant-tag(V)/ returns the tag of a variant /V/ /variant-value(V)/ returns the tagged value of a variant /V/ variant_tag_ fargs = FApp "variant-tag" (FTuple fargs) stepVariant_tag fargs = evalRules [rewrite1] [] where rewrite1 = do let env = emptyEnv env <- vsMatch fargs [PADT "variant" [VPMetaVar "K",VPWildCard]] env rewriteTermTo (TVar "K") env variant_value_ fargs = FApp "variant-value" (FTuple fargs) stepVariant_value fargs = evalRules [rewrite1] [] where rewrite1 = do let env = emptyEnv env <- vsMatch fargs [PADT "variant" [VPWildCard,VPMetaVar "V"]] env rewriteTermTo (TVar "V") env stepVariant vs = rewritten (ADTVal "variant" vs) stepVariants ts = rewriteType "variants" ts