Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,11 @@ jobs:
- name: doctest
run: |
if [ $((HCNUMVER < 91200)) -ne 0 ] ; then cd ${PKGDIR_effectful_core} || false ; fi
if [ $((HCNUMVER < 91200)) -ne 0 ] ; then doctest -XHaskell2010 -XBangPatterns -XConstraintKinds -XDataKinds -XDeriveFunctor -XDeriveGeneric -XDerivingStrategies -XFlexibleContexts -XFlexibleInstances -XGADTs -XGeneralizedNewtypeDeriving -XImportQualifiedPost -XLambdaCase -XMultiParamTypeClasses -XNoStarIsType -XPolyKinds -XRankNTypes -XRoleAnnotations -XScopedTypeVariables -XStandaloneDeriving -XTupleSections -XTypeApplications -XTypeFamilies -XTypeOperators src ; fi
if [ $((HCNUMVER < 91200)) -ne 0 ] ; then doctest -XHaskell2010 -XBangPatterns -XConstraintKinds -XDataKinds -XDeriveFunctor -XDeriveGeneric -XDerivingStrategies -XFlexibleContexts -XFlexibleInstances -XGADTs -XGeneralizedNewtypeDeriving -XImportQualifiedPost -XLambdaCase -XMultiParamTypeClasses -XNoStarIsType -XPolyKinds -XRankNTypes -XRoleAnnotations -XScopedTypeVariables -XStandaloneDeriving -XTupleSections -XTypeApplications -XTypeFamilies -XTypeOperators -XUndecidableInstances src ; fi
if [ $((HCNUMVER < 91200)) -ne 0 ] ; then cd ${PKGDIR_effectful_th} || false ; fi
if [ $((HCNUMVER < 91200)) -ne 0 ] ; then doctest -XHaskell2010 -XBangPatterns -XConstraintKinds -XDataKinds -XDeriveFunctor -XDeriveGeneric -XDerivingStrategies -XFlexibleContexts -XFlexibleInstances -XGADTs -XGeneralizedNewtypeDeriving -XImportQualifiedPost -XLambdaCase -XMultiParamTypeClasses -XNoStarIsType -XPolyKinds -XRankNTypes -XRecordWildCards -XRoleAnnotations -XScopedTypeVariables -XStandaloneDeriving -XTupleSections -XTypeApplications -XTypeFamilies -XTypeOperators src ; fi
if [ $((HCNUMVER < 91200)) -ne 0 ] ; then doctest -XHaskell2010 -XBangPatterns -XConstraintKinds -XDataKinds -XDeriveFunctor -XDeriveGeneric -XDerivingStrategies -XFlexibleContexts -XFlexibleInstances -XGADTs -XGeneralizedNewtypeDeriving -XImportQualifiedPost -XLambdaCase -XMultiParamTypeClasses -XNoStarIsType -XPolyKinds -XRankNTypes -XRecordWildCards -XRoleAnnotations -XScopedTypeVariables -XStandaloneDeriving -XTupleSections -XTypeApplications -XTypeFamilies -XTypeOperators -XUndecidableInstances src ; fi
if [ $((HCNUMVER < 91200)) -ne 0 ] ; then cd ${PKGDIR_effectful} || false ; fi
if [ $((HCNUMVER < 91200)) -ne 0 ] ; then doctest -XHaskell2010 -XBangPatterns -XConstraintKinds -XDataKinds -XDeriveFunctor -XDeriveGeneric -XDerivingStrategies -XFlexibleContexts -XFlexibleInstances -XGADTs -XGeneralizedNewtypeDeriving -XImportQualifiedPost -XLambdaCase -XMultiParamTypeClasses -XNoStarIsType -XPolyKinds -XRankNTypes -XRecordWildCards -XRoleAnnotations -XScopedTypeVariables -XStandaloneDeriving -XTupleSections -XTypeApplications -XTypeFamilies -XTypeOperators src ; fi
if [ $((HCNUMVER < 91200)) -ne 0 ] ; then doctest -XHaskell2010 -XBangPatterns -XConstraintKinds -XDataKinds -XDeriveFunctor -XDeriveGeneric -XDerivingStrategies -XFlexibleContexts -XFlexibleInstances -XGADTs -XGeneralizedNewtypeDeriving -XImportQualifiedPost -XLambdaCase -XMultiParamTypeClasses -XNoStarIsType -XPolyKinds -XRankNTypes -XRecordWildCards -XRoleAnnotations -XScopedTypeVariables -XStandaloneDeriving -XTupleSections -XTypeApplications -XTypeFamilies -XTypeOperators -XUndecidableInstances src ; fi
- name: cabal check
run: |
cd ${PKGDIR_effectful_core} || false
Expand Down
3 changes: 2 additions & 1 deletion doctest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ run_doctest() {
-XTupleSections \
-XTypeApplications \
-XTypeFamilies \
-XTypeOperators
-XTypeOperators \
-XUndecidableInstances
popd
}

Expand Down
4 changes: 4 additions & 0 deletions effectful-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# effectful-core-2.6.1.0 (????-??-??)
* Add `MonadError`, `MonadReader`, `MonadState` and `MonadWriter` instances for
`Eff` for compatibility with existing code.

# effectful-core-2.6.0.0 (2025-06-13)
* Adjust `generalBracket` with `base >= 4.21` to make use of the new exception
annotation mechanism.
Expand Down
4 changes: 3 additions & 1 deletion effectful-core/effectful-core.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 3.0
build-type: Simple
name: effectful-core
version: 2.6.0.0
version: 2.6.1.0
license: BSD-3-Clause
license-file: LICENSE
category: Control
Expand Down Expand Up @@ -60,6 +60,7 @@ common language
TypeApplications
TypeFamilies
TypeOperators
UndecidableInstances

library
import: language
Expand All @@ -70,6 +71,7 @@ library
, containers >= 0.6
, deepseq >= 1.2
, exceptions >= 0.10.4
, mtl >= 2.2.1
, monad-control >= 1.0.3
, primitive >= 0.7.3.0
, strict-mutable-base >= 1.1.0.0
Expand Down
3 changes: 0 additions & 3 deletions effectful-core/src/Effectful/Dispatch/Dynamic.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ImplicitParams #-}
{-# LANGUAGE UndecidableInstances #-}
-- | Dynamically dispatched effects.
module Effectful.Dispatch.Dynamic
( -- * Introduction
Expand Down Expand Up @@ -349,8 +348,6 @@ import Effectful.Internal.Utils
-- __orphan__, __canonical__ instance of @MonadRNG@ for 'Eff' that delegates to
-- the @RNG@ effect:
--
-- >>> :set -XUndecidableInstances
--
-- >>> :{
-- instance RNG :> es => MonadRNG (Eff es) where
-- randomInt = send RandomInt
Expand Down
17 changes: 16 additions & 1 deletion effectful-core/src/Effectful/Error/Dynamic.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{-# OPTIONS_GHC -Wno-orphans #-}
-- | The dynamically dispatched variant of the 'Error' effect.
--
-- /Note:/ unless you plan to change interpretations at runtime, it's
-- /Note:/ unless you plan to change interpretations at runtime or you need the
-- 'MTL.MonadError' instance for compatibility with existing code, it's
-- recommended to use the statically dispatched variant,
-- i.e. "Effectful.Error.Static".
module Effectful.Error.Dynamic
Expand Down Expand Up @@ -28,6 +30,7 @@ module Effectful.Error.Dynamic
, E.prettyCallStack
) where

import Control.Monad.Except qualified as MTL
import GHC.Stack (withFrozenCallStack)

import Effectful
Expand Down Expand Up @@ -148,3 +151,15 @@ tryError
-- ^ The inner computation.
-> Eff es (Either (E.CallStack, e) a)
tryError m = (Right <$> m) `catchError` \es e -> pure $ Left (es, e)

----------------------------------------
-- Orphan instance

-- | Instance included for compatibility with existing code.
instance
( Show e
, Error e :> es
, MTL.MonadError e (Eff es)
) => MTL.MonadError e (Eff es) where
throwError = send . ThrowErrorWith show
catchError action = send . CatchError action . const
1 change: 0 additions & 1 deletion effectful-core/src/Effectful/Internal/Effect.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_HADDOCK not-home #-}
-- | Type-safe indexing for 'Effectful.Internal.Monad.Env'.
--
Expand Down
1 change: 0 additions & 1 deletion effectful-core/src/Effectful/Internal/Monad.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}
{-# OPTIONS_HADDOCK not-home #-}
-- | The 'Eff' monad.
Expand Down
18 changes: 17 additions & 1 deletion effectful-core/src/Effectful/Reader/Dynamic.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{-# OPTIONS_GHC -Wno-orphans #-}
-- | The dynamically dispatched variant of the 'Reader' effect.
--
-- /Note:/ unless you plan to change interpretations at runtime, it's
-- /Note:/ unless you plan to change interpretations at runtime or you need the
-- 'MTL.MonadReader' instance for compatibility with existing code, it's
-- recommended to use the statically dispatched variant,
-- i.e. "Effectful.Reader.Static".
module Effectful.Reader.Dynamic
Expand All @@ -17,6 +19,8 @@ module Effectful.Reader.Dynamic
, local
) where

import Control.Monad.Reader qualified as MTL

import Effectful
import Effectful.Dispatch.Dynamic

Expand Down Expand Up @@ -81,3 +85,15 @@ local
-> Eff es a
-> Eff es a
local f = send . Local f

----------------------------------------
-- Orphan instance

-- | Instance included for compatibility with existing code.
instance
( Reader r :> es
, MTL.MonadReader r (Eff es)
) => MTL.MonadReader r (Eff es) where
ask = send Ask
local f = send . Local f
reader f = f <$> send Ask
18 changes: 17 additions & 1 deletion effectful-core/src/Effectful/State/Dynamic.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{-# OPTIONS_GHC -Wno-orphans #-}
-- | The dynamically dispatched variant of the 'State' effect.
--
-- /Note:/ unless you plan to change interpretations at runtime, it's
-- /Note:/ unless you plan to change interpretations at runtime or you need the
-- 'MTL.MonadState' instance for compatibility with existing code, it's
-- recommended to use one of the statically dispatched variants,
-- i.e. "Effectful.State.Static.Local" or "Effectful.State.Static.Shared".
module Effectful.State.Dynamic
Expand Down Expand Up @@ -29,6 +31,8 @@ module Effectful.State.Dynamic
, modifyM
) where

import Control.Monad.State qualified as MTL

import Effectful
import Effectful.Dispatch.Dynamic
import Effectful.State.Static.Local qualified as L
Expand Down Expand Up @@ -149,3 +153,15 @@ modifyM
=> (s -> Eff es s)
-> Eff es ()
modifyM f = stateM (\s -> ((), ) <$> f s)

----------------------------------------
-- Orphan instance

-- | Instance included for compatibility with existing code.
instance
( State s :> es
, MTL.MonadState s (Eff es)
) => MTL.MonadState s (Eff es) where
get = send Get
put = send . Put
state = send . State
20 changes: 19 additions & 1 deletion effectful-core/src/Effectful/Writer/Dynamic.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{-# OPTIONS_GHC -Wno-orphans #-}
-- | The dynamically dispatched variant of the 'Writer' effect.
--
-- /Note:/ unless you plan to change interpretations at runtime, it's
-- /Note:/ unless you plan to change interpretations at runtime or you need the
-- 'MTL.MonadWriter' instance for compatibility with existing code, it's
-- recommended to use one of the statically dispatched variants,
-- i.e. "Effectful.Writer.Static.Local" or "Effectful.Writer.Static.Shared".
module Effectful.Writer.Dynamic
Expand All @@ -23,6 +25,8 @@ module Effectful.Writer.Dynamic
, listens
) where

import Control.Monad.Writer qualified as MTL

import Effectful
import Effectful.Dispatch.Dynamic
import Effectful.Writer.Static.Local qualified as L
Expand Down Expand Up @@ -102,3 +106,17 @@ listens
listens f m = do
(a, w) <- listen m
pure (a, f w)

----------------------------------------
-- Orphan instance

-- | Instance included for compatibility with existing code.
instance
( Monoid w
, Writer w :> es
, MTL.MonadWriter w (Eff es)
) => MTL.MonadWriter w (Eff es) where
writer (a, w) = a <$ send (Tell w)
tell = send . Tell
listen = send . Listen
pass = error "pass is not implemented due to ambiguous semantics in presence of runtime exceptions"
1 change: 1 addition & 0 deletions effectful-plugin/effectful-plugin.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ common language
TypeApplications
TypeFamilies
TypeOperators
UndecidableInstances

if impl(ghc >= 9.4)
default-extensions: NoFieldSelectors
Expand Down
1 change: 1 addition & 0 deletions effectful-th/effectful-th.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ common language
TypeApplications
TypeFamilies
TypeOperators
UndecidableInstances

library
import: language
Expand Down
2 changes: 2 additions & 0 deletions effectful/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# effectful-2.6.1.0 (????-??-??)
* Add `MonadError`, `MonadReader`, `MonadState` and `MonadWriter` instances for
`Eff` for compatibility with existing code.
* Re-export `writeTMVar` from `stm-2.5.1.0` in `Effectful.Concurrent.STM`.
* Add `cancelMany` to `Effectful.Concurrent.Async`.

Expand Down
1 change: 0 additions & 1 deletion effectful/bench/FileSizes.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE UndecidableInstances #-}
module FileSizes where

import Control.Exception
Expand Down
3 changes: 2 additions & 1 deletion effectful/effectful.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ common language
TypeApplications
TypeFamilies
TypeOperators
UndecidableInstances

library
import: language
Expand All @@ -74,7 +75,7 @@ library
, async >= 2.2.5
, bytestring >= 0.10
, directory >= 1.3.2
, effectful-core >= 2.6.0.0 && < 2.6.1.0
, effectful-core >= 2.6.1.0 && < 2.6.2.0
, process >= 1.6.9
, strict-mutable-base >= 1.1.0.0
, time >= 1.9.2
Expand Down
1 change: 0 additions & 1 deletion effectful/src/Effectful/Concurrent/Async.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{-# LANGUAGE UndecidableInstances #-}
-- | Lifted "Control.Concurrent.Async".
module Effectful.Concurrent.Async
( -- * Effect
Expand Down
Loading