From 938550b784269855dcc2a77a29fc3bbfe181be73 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sat, 22 Jan 2022 16:56:09 +0100 Subject: [PATCH] Add :>> for more concise type signatures --- effectful-core/src/Effectful.hs | 1 + effectful-core/src/Effectful/Internal/Effect.hs | 11 +++++++++++ effectful-core/src/Effectful/Monad.hs | 1 + 3 files changed, 13 insertions(+) diff --git a/effectful-core/src/Effectful.hs b/effectful-core/src/Effectful.hs index 5e02b37d..bc83c155 100644 --- a/effectful-core/src/Effectful.hs +++ b/effectful-core/src/Effectful.hs @@ -7,6 +7,7 @@ module Effectful , Dispatch(..) , DispatchOf , (:>) + , (:>>) -- * Running the 'Eff' monad diff --git a/effectful-core/src/Effectful/Internal/Effect.hs b/effectful-core/src/Effectful/Internal/Effect.hs index 58714a83..84a0fa26 100644 --- a/effectful-core/src/Effectful/Internal/Effect.hs +++ b/effectful-core/src/Effectful/Internal/Effect.hs @@ -8,6 +8,7 @@ module Effectful.Internal.Effect ( Effect , (:>)(..) + , (:>>) -- * Re-exports , Type @@ -51,3 +52,13 @@ instance {-# OVERLAPPING #-} e :> (e : es) where instance e :> es => e :> (x : es) where reifyIndex = 1 + reifyIndex @e @es + +---------------------------------------- + +-- | Convenience operator for expressing that a function uses multiple effects +-- in a more concise way than enumerating them all with '(:>)'. +-- +-- @[E1, E2, ..., En] ':>>' es ≡ (E1 ':>' es, E2 ':>' es, ..., En :> es)@ +type family effs :>> es :: Constraint where + '[] :>> es = () + (e : effs) :>> es = (e :> es, effs :>> es) diff --git a/effectful-core/src/Effectful/Monad.hs b/effectful-core/src/Effectful/Monad.hs index 0e909cc9..0b7bccf0 100644 --- a/effectful-core/src/Effectful/Monad.hs +++ b/effectful-core/src/Effectful/Monad.hs @@ -8,6 +8,7 @@ module Effectful.Monad , Dispatch(..) , DispatchOf , (:>) + , (:>>) -- * Arbitrary I/O , IOE