mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-22 15:58:34 +03:00
Made some FFI related code evaluate things more.
- Previously some foreign values were wrapped up as thunks, which moved around where runtime errors occured a bit.
This commit is contained in:
parent
1c2cdd4a87
commit
de2b83eeb7
@ -33,7 +33,7 @@ import qualified Crypto.Hash as Hash
|
||||
import Unsafe.Coerce
|
||||
|
||||
data Foreign where
|
||||
Wrap :: Reference -> e -> Foreign
|
||||
Wrap :: Reference -> !e -> Foreign
|
||||
|
||||
promote :: (a -> a -> r) -> b -> c -> r
|
||||
promote (~~) x y = unsafeCoerce x ~~ unsafeCoerce y
|
||||
|
@ -16,6 +16,7 @@ import GHC.IO.Exception (IOException(..), IOErrorType(..))
|
||||
import Control.Concurrent (ThreadId)
|
||||
import Control.Concurrent.MVar (MVar)
|
||||
import Control.Concurrent.STM (TVar)
|
||||
import Control.Exception (evaluate)
|
||||
import qualified Data.Char as Char
|
||||
import Data.Foldable (toList)
|
||||
import Data.Text (Text, pack, unpack)
|
||||
@ -95,7 +96,7 @@ instance ForeignConvention Closure where
|
||||
readForeign _ [ ] _ _ = foreignCCError "Closure"
|
||||
writeForeign ustk bstk c = do
|
||||
bstk <- bump bstk
|
||||
(ustk, bstk) <$ poke bstk c
|
||||
(ustk, bstk) <$ (poke bstk =<< evaluate c)
|
||||
|
||||
instance ForeignConvention Text where
|
||||
readForeign = readForeignBuiltin
|
||||
|
Loading…
Reference in New Issue
Block a user