From 88a116cedc8f9ddecfbbb63ca69e9ab7b219e6a2 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Tue, 23 Oct 2018 15:50:42 -0400 Subject: [PATCH] :fire: the demotes. --- src/Data/Abstract/Address/Hole.hs | 14 +++----------- src/Data/Abstract/Address/Located.hs | 14 +++----------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/src/Data/Abstract/Address/Hole.hs b/src/Data/Abstract/Address/Hole.hs index 08dfd8c14..eb991be08 100644 --- a/src/Data/Abstract/Address/Hole.hs +++ b/src/Data/Abstract/Address/Hole.hs @@ -20,20 +20,9 @@ toMaybe (Partial _) = Nothing toMaybe (Total a) = Just a -demoteD :: DerefC (Hole context address) value m a -> DerefC address value m a -demoteD = DerefC . runDerefC - -promoteD :: DerefC address value m a -> DerefC (Hole context address) value m a -promoteD = DerefC . runDerefC - - -demoteA :: AllocatorC (Hole context address) m a -> AllocatorC address m a -demoteA = AllocatorC . runAllocatorC - promoteA :: AllocatorC address m a -> AllocatorC (Hole context address) m a promoteA = AllocatorC . runAllocatorC - instance ( Carrier (Allocator address :+: sig) (AllocatorC address m) , Carrier sig m , Monad m @@ -44,6 +33,9 @@ instance ( Carrier (Allocator address :+: sig) (AllocatorC address m) where alg (Alloc name k) = Total <$> promoteA (eff (L (Alloc name ret))) >>= k +promoteD :: DerefC address value m a -> DerefC (Hole context address) value m a +promoteD = DerefC . runDerefC + instance (Carrier (Deref value :+: sig) (DerefC address value m), Carrier sig m, Monad m) => Carrier (Deref value :+: sig) (DerefC (Hole context address) value m) where ret = promoteD . ret diff --git a/src/Data/Abstract/Address/Located.hs b/src/Data/Abstract/Address/Located.hs index f51b0dde2..94c9ed14d 100644 --- a/src/Data/Abstract/Address/Located.hs +++ b/src/Data/Abstract/Address/Located.hs @@ -20,20 +20,9 @@ data Located address = Located deriving (Eq, Ord, Show) -demoteD :: DerefC (Located address) value m a -> DerefC address value m a -demoteD = DerefC . runDerefC - -promoteD :: DerefC address value m a -> DerefC (Located address) value m a -promoteD = DerefC . runDerefC - - -demoteA :: AllocatorC (Located address) m a -> AllocatorC address m a -demoteA = AllocatorC . runAllocatorC - promoteA :: AllocatorC address m a -> AllocatorC (Located address) m a promoteA = AllocatorC . runAllocatorC - instance ( Carrier (Allocator address :+: sig) (AllocatorC address m) , Carrier sig m , Member (Reader ModuleInfo) sig @@ -47,6 +36,9 @@ instance ( Carrier (Allocator address :+: sig) (AllocatorC address m) where alg (Alloc name k) = Located <$> promoteA (eff (L (Alloc name ret))) <*> currentPackage <*> currentModule <*> pure name <*> ask >>= k +promoteD :: DerefC address value m a -> DerefC (Located address) value m a +promoteD = DerefC . runDerefC + instance (Carrier (Deref value :+: sig) (DerefC address value m), Carrier sig m, Monad m) => Carrier (Deref value :+: sig) (DerefC (Located address) value m) where ret = promoteD . ret