digestive-functors-0.6.2.0: A practical formlet library

Safe HaskellNone

Text.Digestive.Form.Internal

Contents

Description

This module mostly meant for internal usage, and might change between minor releases.

Synopsis

Documentation

type Form v m a = FormTree m v m aSource

Base type for a form.

The three type parameters are:

  • v: the type for textual information, displayed to the user. For example, error messages are of this type. v stands for view.
  • m: the monad in which validators operate. The classical example is when validating input requires access to a database, in which case this m should be an instance of MonadIO.
  • a: the type of the value returned by the form, used for its Applicative instance.

data FormTree t v m a whereSource

Embedded tree structure for forms - the basis for deferred evaluation and the applicative interface.

Constructors

Ref :: Ref -> FormTree t v m a -> FormTree t v m a 
Pure :: Field v a -> FormTree t v m a 
App :: FormTree t v m (b -> a) -> FormTree t v m b -> FormTree t v m a 
Map :: (b -> m (Result v a)) -> FormTree t v m b -> FormTree t v m a 
Monadic :: t (FormTree t v m a) -> FormTree t v m a 
List :: DefaultList (FormTree t v m a) -> FormTree t v m [Int] -> FormTree t v m [a] 
Metadata :: [Metadata] -> FormTree t v m a -> FormTree t v m a 

Instances

Monad m => Functor (FormTree t v m) 
(Monad m, Monoid v) => Applicative (FormTree t v m) 
Show (FormTree Identity v m a) 

data SomeForm v m Source

Value-agnostic Form

Constructors

forall a . SomeForm (FormTree Identity v m a) 

Instances

Show (SomeForm v m) 

type Ref = TextSource

Compact type for form labelling

data Metadata Source

Constructors

Disabled 

transform :: Monad m => (a -> m (Result v b)) -> FormTree t v m a -> FormTree t v m bSource

Map on the value type

monadic :: m (Form v m a) -> Form v m aSource

Hide a monadic wrapper

toFormTree :: Monad m => Form v m a -> m (FormTree Identity v m a)Source

Normalize a Form to allow operations on the contents

children :: FormTree Identity v m a -> [SomeForm v m]Source

Returns the topmost applicative or index trees if either exists otherwise returns an empty list

(.:) :: Monad m => Text -> Form v m a -> Form v m aSource

Operator to set a name for a subform.

getRef :: FormTree Identity v m a -> Maybe RefSource

Return the first/topmost label of a form

lookupForm :: Path -> FormTree Identity v m a -> [SomeForm v m]Source

Retrieve the form(s) at the given path

lookupFormMetadata :: Path -> FormTree Identity v m a -> [(SomeForm v m, [Metadata])]Source

A variant of lookupForm which also returns all metadata associated with the form.

lookupList :: Path -> FormTree Identity v m a -> SomeForm v mSource

Always returns a List - fails if path does not directly reference a list

toField :: FormTree Identity v m a -> Maybe (SomeField v)Source

Returns the topmost untransformed single field, if one exists

queryField :: Path -> FormTree Identity v m a -> (forall b. Field v b -> c) -> cSource

Retrieve the field at the given path of the tree and apply the evaluation. Used in field evaluation functions in View.

eval :: Monad m => Method -> Env m -> FormTree Identity v m a -> m (Result [(Path, v)] a, [(Path, FormInput)])Source

Evaluate a formtree with a given method and environment. Incrementally builds the path based on the set labels and evaluates recursively - applying transformations and applications with a bottom-up strategy.

formMapView :: Monad m => (v -> w) -> FormTree Identity v m a -> FormTree Identity w m aSource

Map on the error type of a FormTree - used to define the Functor instance of View.View

Debugging

debugFormPaths :: Monad m => FormTree Identity v m a -> [Path]Source

Debugging purposes