on master help sign in
Turn off StrictData and make fields lazy where appropriate
commitf68ee2353281ae10d793cd83be33f24731ee1305 authorAndrzej Rybczak <andrzej@rybczak.net> dateWed 28 Jul 2021, 23:41 (5 years ago) parentbd280b4
10 files changed+20−23
doctest.sh−1 effectful-core/effectful-core.cabal−1 effectful-core/src/Effectful/Error.hs+2−2 effectful-core/src/Effectful/Handler.hs+1−1 effectful-core/src/Effectful/Internal/Env.hs+7−7 effectful-core/src/Effectful/Internal/Monad.hs+4−4 effectful-core/src/Effectful/Internal/Unlift.hs+4−4 effectful-core/src/Effectful/State/Dynamic.hs+1−1 effectful-core/src/Effectful/Writer/Dynamic.hs+1−1 effectful/effectful.cabal−1
doctest.sh−1
@@ -29,7 +29,6 @@ run_doctest() {
2929 -XRoleAnnotations \
3030 -XScopedTypeVariables \
3131 -XStandaloneDeriving \
32− -XStrictData \
3332 -XTupleSections \
3433 -XTypeApplications \
3534 -XTypeFamilies \
effectful-core/effectful-core.cabal−1
@@ -47,7 +47,6 @@ common language
4747 RoleAnnotations
4848 ScopedTypeVariables
4949 StandaloneDeriving
50− StrictData
5150 TupleSections
5251 TypeApplications
5352 TypeFamilies
effectful-core/src/Effectful/Error.hs+2−2
@@ -42,7 +42,7 @@ import Effectful.Internal.Effect
4242import Effectful.Internal.Env
4343import Effectful.Internal.Monad
4444
45−data Error e :: Effect where
45+newtype Error e :: Effect where
4646 Error :: ErrorId -> Error e m r
4747
4848runError
@@ -112,7 +112,7 @@ tryHandler ex eid0 handler next = case fromException ex of
112112 | otherwise -> next
113113 Nothing -> next
114114
115−data ErrorEx e = ErrorEx ErrorId CallStack e
115+data ErrorEx e = ErrorEx !ErrorId CallStack e
116116instance Typeable e => Show (ErrorEx e) where
117117 showsPrec p (ErrorEx _ cs e)
118118 = ("Effectful.Error.ErrorEx (" ++)
effectful-core/src/Effectful/Handler.hs+1−1
@@ -55,7 +55,7 @@ type EffectHandler e es
5555 -> Eff es a
5656
5757data Handler :: Effect -> Type where
58− Handler :: Env es -> EffectHandler e es -> Handler e
58+ Handler :: !(Env es) -> !(EffectHandler e es) -> Handler e
5959
6060runHandler :: Handler e -> Eff (e : es) a -> Eff es a
6161runHandler e m = unsafeEff $ \es0 -> do
effectful-core/src/Effectful/Internal/Env.hs+7−7
@@ -109,18 +109,18 @@ type role Env nominal
109109-- - Handler of @e11@ sees @[e00, e02, e03, e12]@.
110110--
111111data Env (es :: [Effect]) = Env
112− { _forks :: Forks
113− , _globalRef :: IORef EnvRef
114− , _forkIdGen :: ForkIdGen
112+ { _forks :: !Forks
113+ , _globalRef :: !(IORef EnvRef)
114+ , _forkIdGen :: !ForkIdGen
115115 }
116116
117117-- | 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
119119
120120data EnvRef = EnvRef
121− { _size :: Int
122− , _data :: SmallMutableArray RealWorld Any
123− , _relinkers :: SmallMutableArray RealWorld Any
121+ { _size :: !Int
122+ , _data :: !(SmallMutableArray RealWorld Any)
123+ , _relinkers :: !(SmallMutableArray RealWorld Any)
124124 }
125125
126126----------------------------------------
effectful-core/src/Effectful/Internal/Monad.hs+4−4
@@ -240,7 +240,7 @@ instance E.MonadMask (Eff es) where
240240----------------------------------------
241241-- Fail
242242
243−data Fail :: Effect where
243+newtype Fail :: Effect where
244244 Fail :: Unique -> Fail m r
245245
246246runFail :: Eff (Fail : es) a -> Eff es (Either String a)
@@ -261,7 +261,7 @@ instance Fail :> es => MonadFail (Eff es) where
261261
262262--------------------
263263
264−data FailEx = FailEx Unique String
264+data FailEx = FailEx !Unique String
265265instance Show FailEx where
266266 showsPrec p (FailEx _ msg)
267267 = ("Effectful.Internal.Monad.FailEx " ++)
@@ -332,7 +332,7 @@ data UnliftStrategy
332332 -- ^ The fastest strategy and a default setting for 'IOE'. An attempt to call
333333 -- the unlifting function in threads distinct from its creator will result in
334334 -- a runtime error.
335− | ConcUnlift Persistence Limit
335+ | ConcUnlift !Persistence !Limit
336336 -- ^ A strategy that makes it possible for the unlifting function to be called
337337 -- in threads distinct from its creator. See 'Persistence' and 'Limit'
338338 -- settings for more information.
@@ -360,7 +360,7 @@ data Persistence
360360
361361-- | Limit setting for the 'ConcUnlift' strategy.
362362data Limit
363− = Limited Int
363+ = Limited !Int
364364 -- ^ Behavior dependent on the 'Persistence' setting.
365365 --
366366 -- 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
120120nextEntryId (EntryId i) = EntryId (i + 1)
121121
122122data ThreadEntries es = ThreadEntries
123− { teCapacity :: Int
124− , teEntries :: IM.IntMap (ThreadEntry es)
123+ { teCapacity :: !Int
124+ , teEntries :: !(IM.IntMap (ThreadEntry es))
125125 }
126126
127127-- | In GHC < 9 weak thread ids are 32bit long, while ThreadIdS are 64bit long,
128128-- so there is potential for collisions. This is solved by keeping, for a
129129-- 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)
131131
132132data ThreadData es
133− = ThreadData EntryId (Weak (ThreadId, Env es)) (ThreadData es)
133+ = ThreadData !EntryId !(Weak (ThreadId, Env es)) (ThreadData es)
134134 | NoThreadData
135135
136136----------------------------------------
effectful-core/src/Effectful/State/Dynamic.hs+1−1
@@ -41,7 +41,7 @@ import qualified Effectful.State.Shared as S
4141-- Whether the state is local or shared depends on the interpretation.
4242data State s :: Effect where
4343 Get :: State s m s
44− Put :: ~s -> State s m ()
44+ Put :: s -> State s m ()
4545 State :: (s -> (a, s)) -> State s m a
4646 StateM :: (s -> m (a, s)) -> State s m a
4747
effectful-core/src/Effectful/Writer/Dynamic.hs+1−1
@@ -21,7 +21,7 @@ import qualified Effectful.Writer.Local as L
2121import qualified Effectful.Writer.Shared as S
2222
2323data Writer w :: Effect where
24− Tell :: ~w -> Writer w m ()
24+ Tell :: w -> Writer w m ()
2525 Listen :: m a -> Writer w m (a, w)
2626
2727----------------------------------------
effectful/effectful.cabal−1
@@ -51,7 +51,6 @@ common language
5151 RoleAnnotations
5252 ScopedTypeVariables
5353 StandaloneDeriving
54− StrictData
5554 TupleSections
5655 TypeApplications
5756 TypeFamilies