From aaf43bda5c50a9d63979db8cb103dd2238c9b658 Mon Sep 17 00:00:00 2001 From: Chris Penner Date: Wed, 16 Oct 2024 17:29:00 -0700 Subject: [PATCH] Fiddling with ref'write conventions --- unison-runtime/src/Unison/Runtime/Builtin.hs | 4 +--- unison-runtime/src/Unison/Runtime/Foreign.hs | 3 --- unison-runtime/src/Unison/Runtime/Stack.hs | 4 ++++ 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/unison-runtime/src/Unison/Runtime/Builtin.hs b/unison-runtime/src/Unison/Runtime/Builtin.hs index 03c35acc7d..ee4ee34ad3 100644 --- a/unison-runtime/src/Unison/Runtime/Builtin.hs +++ b/unison-runtime/src/Unison/Runtime/Builtin.hs @@ -1095,9 +1095,7 @@ ref'read = ref'write :: SuperNormal Symbol ref'write = - binop0 1 $ \[ref, val, unit] -> - TLetD unit BX (TCon Ty.unitRef 0 []) - $ (TPrm WREF [ref, val]) + binop0 0 $ \[ref, val] -> (TPrm WREF [ref, val]) seek'handle :: ForeignOp seek'handle instr = diff --git a/unison-runtime/src/Unison/Runtime/Foreign.hs b/unison-runtime/src/Unison/Runtime/Foreign.hs index d4a8853b48..26e5911d1f 100644 --- a/unison-runtime/src/Unison/Runtime/Foreign.hs +++ b/unison-runtime/src/Unison/Runtime/Foreign.hs @@ -261,9 +261,6 @@ instance BuiltinForeign Value where foreignRef = Tagged Ty.valueRef instance BuiltinForeign TimeSpec where foreignRef = Tagged Ty.timeSpecRef --- TODO: investigate this -instance BuiltinForeign (IORef closure) where foreignRef = Tagged Ty.refRef - data HashAlgorithm where -- Reference is a reference to the hash algorithm HashAlgorithm :: (Hash.HashAlgorithm a) => Reference -> a -> HashAlgorithm diff --git a/unison-runtime/src/Unison/Runtime/Stack.hs b/unison-runtime/src/Unison/Runtime/Stack.hs index 16ba3be3fb..759e732000 100644 --- a/unison-runtime/src/Unison/Runtime/Stack.hs +++ b/unison-runtime/src/Unison/Runtime/Stack.hs @@ -96,6 +96,8 @@ module Unison.Runtime.Stack where import Control.Monad.Primitive +import Data.IORef (IORef) +import Data.Tagged (Tagged (..)) import Data.Word import GHC.Exts as L (IsList (..)) import Unison.Prelude @@ -159,6 +161,8 @@ instance Ord K where newtype Closure = Closure {unClosure :: (GClosure (RComb Closure))} deriving stock (Show, Eq, Ord) +instance BuiltinForeign (IORef Closure) where foreignRef = Tagged Ty.refRef + type IxClosure = GClosure CombIx data GClosure comb