reform-0.2.7.4: reform is a type-safe HTML form generation and validation library

Safe Haskell | None
Language | Haskell98

Control.Applicative.Indexed

Contents

- type-indexed / parameterized classes
- WrappedApplicative

Description

This module provides a type-indexed / parameterized version of the `Functor` and `Applicative` classes.

Synopsis

- class IndexedFunctor f where
  - imap :: (x -> y) -> (a -> b) -> f x a -> f y b
- class IndexedFunctor f => IndexedApplicative f where
  - ipure :: x -> a -> f x a
  - (<<*>>) :: f (x -> y) (a -> b) -> f x a -> f y b
  - (*>>) :: f x a -> f y b -> f y b
  - (<<*) :: f x a -> f y b -> f x a
- (<<$>>) :: IndexedFunctor f => (a -> b) -> f y a -> f y b
- (<<**>>) :: IndexedApplicative f => f x a -> f (x -> y) (a -> b) -> f y b
- liftIA :: IndexedApplicative f => (a -> b) -> (x -> y) -> f a x -> f b y
- liftIA2 :: IndexedApplicative f => (a -> b -> c) -> (x -> y -> z) -> f a x -> f b y -> f c z
- liftIA3 :: IndexedApplicative f => (a -> b -> c -> d) -> (w -> x -> y -> z) -> f a w -> f b x -> f c y -> f d z
- newtype WrappedApplicative f index a = WrappedApplicative {
  - unwrapApplicative :: f a
  }

# type-indexed / parameterized classes

class IndexedFunctor f where Source #

a class for a 'type-indexed' or `paramaterized` functor

note: not sure what the most correct name is for this class, or if it exists in a well supported library already.

Methods

imap Source #

Arguments

:: (x -> y) | function to apply to first parameter
-> (a -> b) | function to apply to second parameter
-> f x a | indexed functor
-> f y b |

imap is similar to fmap

Instances

Functor f => IndexedFunctor (WrappedApplicative f) Source # |
Instance details Defined in Control.Applicative.Indexed Methods imap :: (x -> y) -> (a -> b) -> WrappedApplicative f x a -> WrappedApplicative f y b Source #
Monad m => IndexedFunctor (Form m input view error) Source # |
Instance details Defined in Text.Reform.Core Methods imap :: (x -> y) -> (a -> b) -> Form m input view error x a -> Form m input view error y b Source #

class IndexedFunctor f => IndexedApplicative f where Source #

a class for a 'type-indexed' or `paramaterized` applicative functors

note: not sure what the most correct name is for this class, or if it exists in a well supported library already.

Minimal complete definition

ipure, (<<*>>)

Methods

ipure :: x -> a -> f x a Source #

similar to `pure`

(<<*>>) :: f (x -> y) (a -> b) -> f x a -> f y b infixl 4 Source #

similar to `<*>`

(*>>) :: f x a -> f y b -> f y b infixl 4 Source #

similar to `*>`

(<<*) :: f x a -> f y b -> f x a infixl 4 Source #

similar to `<*`

Instances

Applicative f => IndexedApplicative (WrappedApplicative f) Source # |

Instance details

Defined in Control.Applicative.Indexed

Methods

ipure :: x -> a -> WrappedApplicative f x a Source #

(<<*>>) :: WrappedApplicative f (x -> y) (a -> b) -> WrappedApplicative f x a -> WrappedApplicative f y b Source #

(*>>) :: WrappedApplicative f x a -> WrappedApplicative f y b -> WrappedApplicative f y b Source #

(<<*) :: WrappedApplicative f x a -> WrappedApplicative f y b -> WrappedApplicative f x a Source #

(Monoid view, Monad m) => IndexedApplicative (Form m input error view) Source # |

Instance details

Defined in Text.Reform.Core

Methods

ipure :: x -> a -> Form m input error view x a Source #

(<<*>>) :: Form m input error view (x -> y) (a -> b) -> Form m input error view x a -> Form m input error view y b Source #

(*>>) :: Form m input error view x a -> Form m input error view y b -> Form m input error view y b Source #

(<<*) :: Form m input error view x a -> Form m input error view y b -> Form m input error view x a Source #

(<<$>>) :: IndexedFunctor f => (a -> b) -> f y a -> f y b infixl 4 Source #

similar to `<$>`. An alias for `imap id`

(<<**>>) :: IndexedApplicative f => f x a -> f (x -> y) (a -> b) -> f y b Source #

A variant of `<<*>>` with the arguments reversed.

liftIA :: IndexedApplicative f => (a -> b) -> (x -> y) -> f a x -> f b y Source #

Lift a function to actions. This function may be used as a value for `imap` in a `IndexedFunctor` instance.

liftIA2 :: IndexedApplicative f => (a -> b -> c) -> (x -> y -> z) -> f a x -> f b y -> f c z Source #

Lift a binary function to actions.

liftIA3 :: IndexedApplicative f => (a -> b -> c -> d) -> (w -> x -> y -> z) -> f a w -> f b x -> f c y -> f d z Source #

Lift a binary function to actions.

# WrappedApplicative

newtype WrappedApplicative f index a Source #

a wrapper which lifts a value with an `Applicative` instance so that it can be used as an `IndexedFunctor` or `IndexedApplicative`

    d :: WrappedApplicative Maybe y Char
    d = WrappedApplicative (Just succ) <<*>> WrappedApplicative (Just 'c')

Constructors

WrappedApplicative |

Fields

- unwrapApplicative :: f a

Instances

Applicative f => IndexedApplicative (WrappedApplicative f) Source # |

Instance details

Defined in Control.Applicative.Indexed

Methods

ipure :: x -> a -> WrappedApplicative f x a Source #

(<<*>>) :: WrappedApplicative f (x -> y) (a -> b) -> WrappedApplicative f x a -> WrappedApplicative f y b Source #

(*>>) :: WrappedApplicative f x a -> WrappedApplicative f y b -> WrappedApplicative f y b Source #

(<<*) :: WrappedApplicative f x a -> WrappedApplicative f y b -> WrappedApplicative f x a Source #

Functor f => IndexedFunctor (WrappedApplicative f) Source # |
Instance details Defined in Control.Applicative.Indexed Methods imap :: (x -> y) -> (a -> b) -> WrappedApplicative f x a -> WrappedApplicative f y b Source #
Monad f => Monad (WrappedApplicative f index) Source # |
Instance details Defined in Control.Applicative.Indexed Methods (>>=) :: WrappedApplicative f index a -> (a -> WrappedApplicative f index b) -> WrappedApplicative f index b Source # (>>) :: WrappedApplicative f index a -> WrappedApplicative f index b -> WrappedApplicative f index b Source # return :: a -> WrappedApplicative f index a Source # fail :: String -> WrappedApplicative f index a Source #
Functor f => Functor (WrappedApplicative f index) Source # |
Instance details Defined in Control.Applicative.Indexed Methods fmap :: (a -> b) -> WrappedApplicative f index a -> WrappedApplicative f index b Source # (<$) :: a -> WrappedApplicative f index b -> WrappedApplicative f index a Source #
Applicative f => Applicative (WrappedApplicative f index) Source # |

Instance details

Defined in Control.Applicative.Indexed

Methods

pure :: a -> WrappedApplicative f index a Source #

(<*>) :: WrappedApplicative f index (a -> b) -> WrappedApplicative f index a -> WrappedApplicative f index b Source #

liftA2 :: (a -> b -> c) -> WrappedApplicative f index a -> WrappedApplicative f index b -> WrappedApplicative f index c Source #

(*>) :: WrappedApplicative f index a -> WrappedApplicative f index b -> WrappedApplicative f index b Source #

(<*) :: WrappedApplicative f index a -> WrappedApplicative f index b -> WrappedApplicative f index a Source #

Eq (f a) => Eq (WrappedApplicative f index a) Source # |
Instance details Defined in Control.Applicative.Indexed Methods (==) :: WrappedApplicative f index a -> WrappedApplicative f index a -> Bool Source # (/=) :: WrappedApplicative f index a -> WrappedApplicative f index a -> Bool Source #
Ord (f a) => Ord (WrappedApplicative f index a) Source # |

Instance details

Defined in Control.Applicative.Indexed

Methods

compare :: WrappedApplicative f index a -> WrappedApplicative f index a -> Ordering Source #

(<) :: WrappedApplicative f index a -> WrappedApplicative f index a -> Bool Source #

(<=) :: WrappedApplicative f index a -> WrappedApplicative f index a -> Bool Source #

(>) :: WrappedApplicative f index a -> WrappedApplicative f index a -> Bool Source #

(>=) :: WrappedApplicative f index a -> WrappedApplicative f index a -> Bool Source #

max :: WrappedApplicative f index a -> WrappedApplicative f index a -> WrappedApplicative f index a Source #

min :: WrappedApplicative f index a -> WrappedApplicative f index a -> WrappedApplicative f index a Source #

Read (f a) => Read (WrappedApplicative f index a) Source # |
Instance details Defined in Control.Applicative.Indexed Methods readsPrec :: Int -> ReadS (WrappedApplicative f index a) Source # readList :: ReadS [WrappedApplicative f index a] Source # readPrec :: ReadPrec (WrappedApplicative f index a) Source # readListPrec :: ReadPrec [WrappedApplicative f index a] Source #
Show (f a) => Show (WrappedApplicative f index a) Source # |
Instance details Defined in Control.Applicative.Indexed Methods showsPrec :: Int -> WrappedApplicative f index a -> ShowS Source # show :: WrappedApplicative f index a -> String Source # showList :: [WrappedApplicative f index a] -> ShowS Source #