wizard-0.1.1: the fantastical wizard monoid

Wizard

Synopsis

Documentation

newtype WizardT m a infixr 9 Source #

A Wizard Monoid, based on ideas expressed by Gabriel Gonzalez at http://www.haskellforall.com/2018/02/the-wizard-monoid.html.

One can view this as Compose, specialised to a single functor.

Constructors

 WizardT infixr 9 Fieldswand :: m (m a)
Instances

Fantastical use of a Wizard

egg :: (Applicative f, Monoid a) => WizardT f a Source #

O(1) fantastical - construct an empty Wizard.

tadpole :: Applicative f => a -> WizardT f a Source #

O(1) fantastical - construct a singleton Wizard.

transform :: Functor f => (a -> b) -> WizardT f a -> WizardT f b Source #

Map over a Wizard in a fantastical manner.

essence :: Monad m => WizardT m a -> m a Source #

Get the input (essence) out of the Wizard.

leviosa :: Monad m => m a -> WizardT m a Source #

Lift an input into a Wizard.

summon :: Monad m => (a -> WizardT m b) -> m a -> WizardT m b Source #

Summon a Wizard out of a monad using a conjuring spell.

 (>>=) = flip summon . essence

sageMode :: forall m t a b. (Monad m, Foldable t, Monoid a, Monoid b) => (a -> WizardT m b) -> t a -> m b Source #

Run an action over a collection of inputs fantastically.

This is like 'Beast Mode', but specialised to Wizards.

Boring use of a Wizard

empty :: (Applicative f, Monoid a) => WizardT f a Source #

O(1) boring - construct an empty Wizard.

singleton :: Applicative f => a -> WizardT f a Source #

O(1) boring - construct a singleton Wizard.

mapWizard :: Functor f => (a -> b) -> WizardT f a -> WizardT f b Source #

Map over a Wizard in a boring manner.

foldWizard :: forall m t a b. (Monad m, Foldable t, Monoid a, Monoid b) => (a -> WizardT m b) -> t a -> m b Source #

Run an action over a collection of inputs.