HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Modulefused-effects-1.1.2.7Haskell2010

Control.Effect.Sum

Operations on sums, combining effects into a signature.

Contents
  1. Membership
  2. Sums
Synopsis

Membership

classclass Member (sub :: (Type -> Type) -> Type -> Type) (sup :: (Type -> Type) -> Type -> Type) where

The class of types present in a signature.

This is based on Wouter Swierstra’s design described in Data types à la carte. As described therein, overlapping instances are required in order to distinguish e.g. left-occurrence from right-recursion.

It should not generally be necessary for you to define new Member instances, but these are not specifically prohibited if you wish to get creative.

Methods

  • inj :: sub m a -> sup m a

    Inject a member of a signature into the signature.

Instances4Member
  • Member t tDefined in fused-effects-1.1.2.7 · Control.Effect.Sum

    Reflexivity: t is a member of itself.

  • Member l (l :+: r)Defined in fused-effects-1.1.2.7 · Control.Effect.Sum

    Left-occurrence: if t is at the head of a signature, we can inject it in O(1).

  • Member l r => Member l (l' :+: r)Defined in fused-effects-1.1.2.7 · Control.Effect.Sum

    Right-recursion: if t is a member of r, we can inject it into r in O(n), followed by lifting that into l :+: r in O(1).

  • Member t (l1 :+: (l2 :+: r)) => Member t ((l1 :+: l2) :+: r)Defined in fused-effects-1.1.2.7 · Control.Effect.Sum

    Left-recursion: if t is a member of l1 :+: l2 :+: r, then we can inject it into (l1 :+: l2) :+: r by injection into a right-recursive signature, followed by left-association.

familytype family Members (sub :: (Type -> Type) -> Type -> Type) (sup :: (Type -> Type) -> Type -> Type) :: Constraint where

Decompose sums on the left into multiple Member constraints.

Note that while this, and by extension Has, can be used to group together multiple membership checks into a single (composite) constraint, large signatures on the left can slow compiles down due to a problem with recursive type families.

Equations

Sums

datadata (:+:) (f :: (Type -> Type) -> Type -> Type) (g :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) k

Higher-order sums are used to combine multiple effects into a signature, typically by chaining on the right.

Constructors

  • L (f m k)
  • R (g m k)
Instances54LabelledMember, Member, Algebra, Functor, Foldable, Traversable, …