packages feed

funcons-tools-0.1.0.0: cbs/Funcons/Core/Abstractions/Patterns/PatternPrefer.hs

-- GeNeRaTeD fOr: ../../CBS/Funcons/Abstractions/Patterns/pattern-prefer.aterm
{-# LANGUAGE OverloadedStrings #-}

module Funcons.Core.Abstractions.Patterns.PatternPrefer where

import Funcons.EDSL

entities = []

types = typeEnvFromList
    []

funcons = libFromList
    [("pattern-prefer",StrictFuncon stepPattern_prefer)]

-- |
-- /pattern-prefer(P1,P2)/ is a pattern that attempts to match the value against
--   /P1/ .  If this succeeds then the resulting environment is returned.
--   Otherwise, the value is matched against /P2/ . 
pattern_prefer_ fargs = FApp "pattern-prefer" (FTuple fargs)
stepPattern_prefer fargs =
    evalRules [rewrite1] []
    where rewrite1 = do
            let env = emptyEnv
            env <- vsMatch fargs [VPAnnotated (VPMetaVar "P1") (TName "values"),VPAnnotated (VPMetaVar "P2") (TName "values")] env
            rewriteTermTo (TApp "thunk" (TTuple [TApp "else" (TTuple [TApp "match" (TTuple [TName "given",TVar "P1"]),TApp "match" (TTuple [TName "given",TVar "P2"])])])) env