on master help sign in
Turn off StrictData and make fields lazy where appropriate
f68ee23Andrzej Rybczak
doctest.sh−1
@@ -29,7 +29,6 @@ run_doctest() {
29 -XRoleAnnotations \
29 -XRoleAnnotations \
30 -XScopedTypeVariables \
30 -XScopedTypeVariables \
31 -XStandaloneDeriving \
31 -XStandaloneDeriving \
32− -XStrictData \
33 -XTupleSections \
32 -XTupleSections \
34 -XTypeApplications \
33 -XTypeApplications \
35 -XTypeFamilies \
34 -XTypeFamilies \
effectful-core/effectful-core.cabal−1
@@ -47,7 +47,6 @@ common language
47 RoleAnnotations
47 RoleAnnotations
48 ScopedTypeVariables
48 ScopedTypeVariables
49 StandaloneDeriving
49 StandaloneDeriving
50− StrictData
51 TupleSections
50 TupleSections
52 TypeApplications
51 TypeApplications
53 TypeFamilies
52 TypeFamilies
effectful-core/src/Effectful/Error.hs+2−2
@@ -42,7 +42,7 @@ import Effectful.Internal.Effect
42import Effectful.Internal.Env
42import Effectful.Internal.Env
43import Effectful.Internal.Monad
43import Effectful.Internal.Monad
44
44
45−data Error e :: Effect where
45+newtype Error e :: Effect where
46 Error :: ErrorId -> Error e m r
46 Error :: ErrorId -> Error e m r
47
47
48runError
48runError
@@ -112,7 +112,7 @@ tryHandler ex eid0 handler next = case fromException ex of
112 | otherwise -> next
112 | otherwise -> next
113 Nothing -> next
113 Nothing -> next
114
114
115−data ErrorEx e = ErrorEx ErrorId CallStack e
115+data ErrorEx e = ErrorEx !ErrorId CallStack e
116instance Typeable e => Show (ErrorEx e) where
116instance Typeable e => Show (ErrorEx e) where
117 showsPrec p (ErrorEx _ cs e)
117 showsPrec p (ErrorEx _ cs e)
118 = ("Effectful.Error.ErrorEx (" ++)
118 = ("Effectful.Error.ErrorEx (" ++)
effectful-core/src/Effectful/Handler.hs+1−1
@@ -55,7 +55,7 @@ type EffectHandler e es
55 -> Eff es a
55 -> Eff es a
56
56
57data Handler :: Effect -> Type where
57data Handler :: Effect -> Type where
58− Handler :: Env es -> EffectHandler e es -> Handler e
58+ Handler :: !(Env es) -> !(EffectHandler e es) -> Handler e
59
59
60runHandler :: Handler e -> Eff (e : es) a -> Eff es a
60runHandler :: Handler e -> Eff (e : es) a -> Eff es a
61runHandler e m = unsafeEff $ \es0 -> do
61runHandler e m = unsafeEff $ \es0 -> do
effectful-core/src/Effectful/Internal/Env.hs+7−7
@@ -109,18 +109,18 @@ type role Env nominal
109-- - Handler of @e11@ sees @[e00, e02, e03, e12]@.
109-- - Handler of @e11@ sees @[e00, e02, e03, e12]@.
110--
110--
111data Env (es :: [Effect]) = Env
111data Env (es :: [Effect]) = Env
112− { _forks :: Forks
112+ { _forks :: !Forks
113− , _globalRef :: IORef EnvRef
113+ , _globalRef :: !(IORef EnvRef)
114− , _forkIdGen :: ForkIdGen
114+ , _forkIdGen :: !ForkIdGen
115 }
115 }
116
116
117-- | Local forks of the environment.
117-- | Local forks of the environment.
118−data Forks = Forks ForkId Int (IORef EnvRef) Forks | NoFork
118+data Forks = Forks !ForkId !Int !(IORef EnvRef) Forks | NoFork
119
119
120data EnvRef = EnvRef
120data EnvRef = EnvRef
121− { _size :: Int
121+ { _size :: !Int
122− , _data :: SmallMutableArray RealWorld Any
122+ , _data :: !(SmallMutableArray RealWorld Any)
123− , _relinkers :: SmallMutableArray RealWorld Any
123+ , _relinkers :: !(SmallMutableArray RealWorld Any)
124 }
124 }
125
125
126----------------------------------------
126----------------------------------------
effectful-core/src/Effectful/Internal/Monad.hs+4−4
@@ -240,7 +240,7 @@ instance E.MonadMask (Eff es) where
240----------------------------------------
240----------------------------------------
241-- Fail
241-- Fail
242
242
243−data Fail :: Effect where
243+newtype Fail :: Effect where
244 Fail :: Unique -> Fail m r
244 Fail :: Unique -> Fail m r
245
245
246runFail :: Eff (Fail : es) a -> Eff es (Either String a)
246runFail :: Eff (Fail : es) a -> Eff es (Either String a)
@@ -261,7 +261,7 @@ instance Fail :> es => MonadFail (Eff es) where
261
261
262--------------------
262--------------------
263
263
264−data FailEx = FailEx Unique String
264+data FailEx = FailEx !Unique String
265instance Show FailEx where
265instance Show FailEx where
266 showsPrec p (FailEx _ msg)
266 showsPrec p (FailEx _ msg)
267 = ("Effectful.Internal.Monad.FailEx " ++)
267 = ("Effectful.Internal.Monad.FailEx " ++)
@@ -332,7 +332,7 @@ data UnliftStrategy
332 -- ^ The fastest strategy and a default setting for 'IOE'. An attempt to call
332 -- ^ The fastest strategy and a default setting for 'IOE'. An attempt to call
333 -- the unlifting function in threads distinct from its creator will result in
333 -- the unlifting function in threads distinct from its creator will result in
334 -- a runtime error.
334 -- a runtime error.
335− | ConcUnlift Persistence Limit
335+ | ConcUnlift !Persistence !Limit
336 -- ^ A strategy that makes it possible for the unlifting function to be called
336 -- ^ A strategy that makes it possible for the unlifting function to be called
337 -- in threads distinct from its creator. See 'Persistence' and 'Limit'
337 -- in threads distinct from its creator. See 'Persistence' and 'Limit'
338 -- settings for more information.
338 -- settings for more information.
@@ -360,7 +360,7 @@ data Persistence
360
360
361-- | Limit setting for the 'ConcUnlift' strategy.
361-- | Limit setting for the 'ConcUnlift' strategy.
362data Limit
362data Limit
363− = Limited Int
363+ = Limited !Int
364 -- ^ Behavior dependent on the 'Persistence' setting.
364 -- ^ Behavior dependent on the 'Persistence' setting.
365 --
365 --
366 -- For 'Ephemeral', it limits the amount of uses of the unlifting function in
366 -- For 'Ephemeral', it limits the amount of uses of the unlifting function in
effectful-core/src/Effectful/Internal/Unlift.hs+4−4
@@ -120,17 +120,17 @@ nextEntryId :: EntryId -> EntryId
120nextEntryId (EntryId i) = EntryId (i + 1)
120nextEntryId (EntryId i) = EntryId (i + 1)
121
121
122data ThreadEntries es = ThreadEntries
122data ThreadEntries es = ThreadEntries
123− { teCapacity :: Int
123+ { teCapacity :: !Int
124− , teEntries :: IM.IntMap (ThreadEntry es)
124+ , teEntries :: !(IM.IntMap (ThreadEntry es))
125 }
125 }
126
126
127-- | In GHC < 9 weak thread ids are 32bit long, while ThreadIdS are 64bit long,
127-- | In GHC < 9 weak thread ids are 32bit long, while ThreadIdS are 64bit long,
128-- so there is potential for collisions. This is solved by keeping, for a
128-- so there is potential for collisions. This is solved by keeping, for a
129-- particular weak thread id, a list of ThreadIdS with unique EntryIdS.
129-- particular weak thread id, a list of ThreadIdS with unique EntryIdS.
130−data ThreadEntry es = ThreadEntry EntryId (ThreadData es)
130+data ThreadEntry es = ThreadEntry !EntryId !(ThreadData es)
131
131
132data ThreadData es
132data ThreadData es
133− = ThreadData EntryId (Weak (ThreadId, Env es)) (ThreadData es)
133+ = ThreadData !EntryId !(Weak (ThreadId, Env es)) (ThreadData es)
134 | NoThreadData
134 | NoThreadData
135
135
136----------------------------------------
136----------------------------------------
effectful-core/src/Effectful/State/Dynamic.hs+1−1
@@ -41,7 +41,7 @@ import qualified Effectful.State.Shared as S
41-- Whether the state is local or shared depends on the interpretation.
41-- Whether the state is local or shared depends on the interpretation.
42data State s :: Effect where
42data State s :: Effect where
43 Get :: State s m s
43 Get :: State s m s
44− Put :: ~s -> State s m ()
44+ Put :: s -> State s m ()
45 State :: (s -> (a, s)) -> State s m a
45 State :: (s -> (a, s)) -> State s m a
46 StateM :: (s -> m (a, s)) -> State s m a
46 StateM :: (s -> m (a, s)) -> State s m a
47
47
effectful-core/src/Effectful/Writer/Dynamic.hs+1−1
@@ -21,7 +21,7 @@ import qualified Effectful.Writer.Local as L
21import qualified Effectful.Writer.Shared as S
21import qualified Effectful.Writer.Shared as S
22
22
23data Writer w :: Effect where
23data Writer w :: Effect where
24− Tell :: ~w -> Writer w m ()
24+ Tell :: w -> Writer w m ()
25 Listen :: m a -> Writer w m (a, w)
25 Listen :: m a -> Writer w m (a, w)
26
26
27----------------------------------------
27----------------------------------------
effectful/effectful.cabal−1
@@ -51,7 +51,6 @@ common language
51 RoleAnnotations
51 RoleAnnotations
52 ScopedTypeVariables
52 ScopedTypeVariables
53 StandaloneDeriving
53 StandaloneDeriving
54− StrictData
55 TupleSections
54 TupleSections
56 TypeApplications
55 TypeApplications
57 TypeFamilies
56 TypeFamilies