From 5e4e586f2d11d220efc043c84ae7c373a4e55463 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 18 Jun 2018 09:50:04 -0400 Subject: [PATCH] Define a define helper for defining definitions. --- src/Control/Abstract/Primitive.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Control/Abstract/Primitive.hs b/src/Control/Abstract/Primitive.hs index a624c2e78..65a704f2d 100644 --- a/src/Control/Abstract/Primitive.hs +++ b/src/Control/Abstract/Primitive.hs @@ -24,6 +24,20 @@ builtin s def = withCurrentCallStack callStack $ do bind name' addr def >>= assign addr +define :: ( HasCallStack + , Member (Allocator address value) effects + , Member (Env address) effects + , Member (Reader ModuleInfo) effects + , Member (Reader Span) effects + ) + => Name + -> Evaluator address value effects value + -> Evaluator address value effects () +define name def = withCurrentCallStack callStack $ do + addr <- alloc name + bind name addr + def >>= assign addr + lambda :: (AbstractFunction address value effects, Member Fresh effects) => (Name -> Evaluator address value effects address) -> Evaluator address value effects value