packages feed

funcons-tools-0.1.0.0: cbs/Funcons/Core/Abstractions/Closures/Closure.hs

-- GeNeRaTeD fOr: ../../CBS/Funcons/Abstractions/Closures/closure.aterm
{-# LANGUAGE OverloadedStrings #-}

module Funcons.Core.Abstractions.Closures.Closure where

import Funcons.EDSL

entities = []

types = typeEnvFromList
    []

funcons = libFromList
    [("closure",PartiallyStrictFuncon [NonStrict,Strict] stepClosure)]

-- |
-- /closure(X,Rho)/ evaluates /X/ using /Rho/ as the current environment.
closure_ fargs = FApp "closure" (FTuple fargs)
stepClosure fargs@[arg1,arg2] =
    evalRules [rewrite1] [step1]
    where rewrite1 = do
            let env = emptyEnv
            env <- fsMatch fargs [PAnnotated (PMetaVar "V") (TName "values"),PAnnotated (PWildCard) (TName "environments")] env
            rewriteTermTo (TVar "V") env
          step1 = do
            let env = emptyEnv
            env <- lifted_fsMatch fargs [PMetaVar "X",PAnnotated (PMetaVar "Rho") (TName "environments")] env
            env <- getInhPatt "environment" (VPWildCard) env
            env <- withInhTerm "environment" (TTuple [TVar "Rho"]) env (premise (TVar "X") (PMetaVar "X'") env)
            stepTermTo (TApp "closure" (TTuple [TVar "X'",TVar "Rho"])) env
stepClosure fargs = sortErr (FApp "closure" (FTuple fargs)) "invalid number of arguments"