-- GeNeRaTeD fOr: ../../CBS/Funcons/Abstractions/Patterns/case.aterm {-# LANGUAGE OverloadedStrings #-} module Funcons.Core.Abstractions.Patterns.Case where import Funcons.EDSL entities = [] types = typeEnvFromList [] funcons = libFromList [("case",PartiallyStrictFuncon [Strict,NonStrict] stepCase)] -- | -- /case(P,X)/ attempts to match the (potentially composite) /given-value/ against the (potentially composite) pattern /P/ . -- If successful, /X/ is executed in the scope of any computed bindings. -- Otherwise, it fails. case_ fargs = FApp "case" (FTuple fargs) stepCase fargs@[arg1,arg2] = evalRules [rewrite1] [] where rewrite1 = do let env = emptyEnv env <- fsMatch fargs [PAnnotated (PMetaVar "P") (TName "values"),PMetaVar "F"] env rewriteTermTo (TApp "scope" (TTuple [TApp "match" (TTuple [TName "given",TVar "P"]),TVar "F"])) env stepCase fargs = sortErr (FApp "case" (FTuple fargs)) "invalid number of arguments"