packages feed

funcons-tools-0.1.0.0: cbs/Funcons/Core/Computations/DataFlow/Giving/Give.hs

-- GeNeRaTeD fOr: ../../CBS/Funcons/Computations/Data flow/Giving/give.aterm
{-# LANGUAGE OverloadedStrings #-}

module Funcons.Core.Computations.DataFlow.Giving.Give where

import Funcons.EDSL

entities = []

types = typeEnvFromList
    []

funcons = libFromList
    [("give",PartiallyStrictFuncon [Strict,NonStrict] stepGive)]

-- |
-- /give(V,X)/ evaluates /X/ with /V/ as the given value.
give_ fargs = FApp "give" (FTuple fargs)
stepGive fargs@[arg1,arg2] =
    evalRules [rewrite1] [step1]
    where rewrite1 = do
            let env = emptyEnv
            env <- fsMatch fargs [PAnnotated (PWildCard) (TName "values"),PAnnotated (PMetaVar "V") (TName "values")] env
            rewriteTermTo (TVar "V") env
          step1 = do
            let env = emptyEnv
            env <- lifted_fsMatch fargs [PAnnotated (PMetaVar "V") (TName "values"),PMetaVar "X"] env
            env <- getInhPatt "given-value" (VPWildCard) env
            env <- withInhTerm "given-value" (TTuple [TVar "V"]) env (premise (TVar "X") (PMetaVar "X'") env)
            stepTermTo (TApp "give" (TTuple [TVar "V",TVar "X'"])) env
stepGive fargs = sortErr (FApp "give" (FTuple fargs)) "invalid number of arguments"