From 4b4cea587f127e9c65bb0c226068411a184f706c Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 14 Mar 2018 15:06:40 -0400 Subject: [PATCH] letrec returns the address. --- src/Control/Abstract/Addressable.hs | 4 ++-- src/Control/Abstract/Value.hs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Control/Abstract/Addressable.hs b/src/Control/Abstract/Addressable.hs index 68048ddbc..047ec4b26 100644 --- a/src/Control/Abstract/Addressable.hs +++ b/src/Control/Abstract/Addressable.hs @@ -56,12 +56,12 @@ letrec :: ( MonadAddressable (LocationFor value) value m ) => Name -> m value - -> m value + -> m (value, Address (LocationFor value) value) letrec name body = do addr <- alloc name v <- localEnv (envInsert name addr) body assign addr v - pure v + pure (v, addr) -- Instances diff --git a/src/Control/Abstract/Value.hs b/src/Control/Abstract/Value.hs index 7bd0c91cc..df7d19d4e 100644 --- a/src/Control/Abstract/Value.hs +++ b/src/Control/Abstract/Value.hs @@ -118,7 +118,7 @@ loop :: ( MonadAddressable (LocationFor value) value m ) => m value -> m value -loop = letrec (name "loop") +loop = fmap fst . letrec (name "loop") continue :: ( MonadAddressable (LocationFor value) value m , MonadEnvironment value m