ref: 82bd1352447ef7b10b123f41a6b41ca085543574
parent: 164a61a6f870735bb4726a3910aed985279be9b9
author: Lennart Augustsson <lennart@augustsson.net>
date: Sun Oct 13 16:25:56 EDT 2024
Leaner Typeable
--- a/TODO
+++ b/TODO
@@ -6,11 +6,8 @@
- instead of skolemization, use regular variables, making sure they are unique
* Redo type synonym expansion
- Do expansion during unification
-* Redo handling of synonym and instance tables.
- - These tables can persist during the compilation and only grow
* Implement two level tables for instances even in the tricky cases
* Removing [] from prim table
-* Faster compression
* Use pointer reversal during marking, will be slower
* Fix bug uncovered by Data.Type.Equality
* mkQIdent
@@ -26,15 +23,13 @@
* Ad hoc fix for f.g: check if g is a field
* Divide lib into different packages
* Sync lib with GHC base
-* Handle closing of Handle properly (don't crash on multiple close)
- - implement ForeignPtr with finalizers for this.
* Use finalizers for alloca?
* Better naming of internal identifiers
* Add mask&co to exceptions
-* Make deriving refer to identifiers that don't need to be in scope
* Add reductions for underapplied K2,K3,K4
-* Move some Typeable instances from the class file to ST&co (makes it leaner)
* Make a Unicode version of Data.Char
+ - make tables using the Haskell tools
+ - read tables lazily when outside ASCII range
Bugs:
* Missing IO in ccall shows wrong location
--- a/lib/Control/Monad/ST_Type.hs
+++ b/lib/Control/Monad/ST_Type.hs
@@ -4,8 +4,11 @@
) where
import Prelude() -- do not import Prelude
import Primitives(IO)
+import {-# SOURCE #-} Data.Typeable
-- The ST monad is implemented with the IO monad.
newtype ST s a = ST (IO a)
+ deriving (Typeable)
+
unST :: forall s a . ST s a -> IO a
unST (ST io) = io
--- a/lib/Data/IORef.hs
+++ b/lib/Data/IORef.hs
@@ -8,9 +8,11 @@
import Prelude() -- do not import Prelude
import Primitives
import Data.Eq
+import {-# SOURCE #-} Data.Typeable
-- An IORef is represented as an IOArray with a single element.
newtype IORef a = R (IOArray a)
+ deriving (Typeable)
instance forall a . Eq (IORef a) where
R x == R y = primArrEQ x y
--- a/lib/Data/STRef.hs
+++ b/lib/Data/STRef.hs
@@ -5,8 +5,10 @@
import Prelude(); import MiniPrelude
import Control.Monad.ST_Type
import Data.IORef
+import {-# SOURCE #-} Data.Typeable
newtype STRef s a = R (IORef a)
+ deriving (Typeable)
newSTRef :: forall s a . a -> ST s (STRef s a)
newSTRef a = ST (R <$> newIORef a)
--- a/lib/Data/Typeable.hs
+++ b/lib/Data/Typeable.hs
@@ -19,13 +19,10 @@
) where
import Prelude(); import MiniPrelude
import Primitives
-import Control.Monad.ST
import Data.Double
import Data.Integer
-import Data.IORef
import Data.Proxy
import Data.Ratio
-import Data.STRef
import Data.Type.Equality
import Data.Void
import Data.Word
@@ -159,8 +156,9 @@
instance Typeable IO where typeRep = prim "IO"
instance Typeable Ptr where typeRep = prim "Ptr"
+instance Typeable FunPtr where typeRep = prim "FunPtr"
+instance Typeable ForeignPtr where typeRep = prim "ForeignPtr"
instance Typeable IOArray where typeRep = prim "IOArray"
-instance Typeable IORef where typeRep = nullary "Data.IORef" "IORef"
instance Typeable [] where typeRep = nullary "Data.List_Type" "[]"
instance Typeable Maybe where typeRep = nullary "Data.Maybe_Type" "Maybe"
@@ -173,8 +171,6 @@
instance Typeable (,) where typeRep = nullary "Data.Tuple" ","
instance Typeable (->) where typeRep = prim "->"
instance Typeable Either where typeRep = nullary "Data.Either" "Either"
-instance Typeable ST where typeRep = nullary "Control.Monad.ST" "ST"
-instance Typeable STRef where typeRep = nullary "Data.STRef" "STRef"
instance Typeable (,,) where typeRep = nullary "Data.Tuple" ",,"
instance Typeable (,,,) where typeRep = nullary "Data.Tuple" ",,,"