{-# LANGUAGE
ScopedTypeVariables
, TypeFamilies
#-}
module Ditto.Generalized.Unnamed
( G.Choice(..)
, input
, inputMaybe
, inputNoData
, inputFile
, inputMulti
, inputChoice
, inputList
, label
, errors
, childErrors
, withErrors
, G.withChildErrors
) where
import Data.List.NonEmpty (NonEmpty(..))
import Ditto.Backend
import Ditto.Core
import Ditto.Types
import qualified Ditto.Generalized.Internal as G
input :: (Environment m input, FormError input err)
=> (input -> Either err a)
-> (FormId -> a -> view)
-> a
-> Form m input err view a
input :: (input -> Either err a)
-> (FormId -> a -> view) -> a -> Form m input err view a
input = FormState m FormId
-> (input -> Either err a)
-> (FormId -> a -> view)
-> a
-> Form m input err view a
forall (m :: * -> *) input err a view.
(Environment m input, FormError input err) =>
FormState m FormId
-> (input -> Either err a)
-> (FormId -> a -> view)
-> a
-> Form m input err view a
G.input FormState m FormId
forall (m :: * -> *). Monad m => FormState m FormId
getFormId
inputMaybe :: (Environment m input, FormError input err)
=> (input -> Either err a)
-> (FormId -> Maybe a -> view)
-> Maybe a
-> Form m input err view (Maybe a)
inputMaybe :: (input -> Either err a)
-> (FormId -> Maybe a -> view)
-> Maybe a
-> Form m input err view (Maybe a)
inputMaybe = FormState m FormId
-> (input -> Either err a)
-> (FormId -> Maybe a -> view)
-> Maybe a
-> Form m input err view (Maybe a)
forall (m :: * -> *) input err a view.
(Monad m, FormError input err, Environment m input) =>
FormState m FormId
-> (input -> Either err a)
-> (FormId -> Maybe a -> view)
-> Maybe a
-> Form m input err view (Maybe a)
G.inputMaybe FormState m FormId
forall (m :: * -> *). Monad m => FormState m FormId
getFormId
inputNoData :: (Environment m input)
=> (FormId -> view)
-> Form m input err view ()
inputNoData :: (FormId -> view) -> Form m input err view ()
inputNoData = FormState m FormId -> (FormId -> view) -> Form m input err view ()
forall (m :: * -> *) view input err.
Monad m =>
FormState m FormId -> (FormId -> view) -> Form m input err view ()
G.inputNoData FormState m FormId
forall (m :: * -> *). Monad m => FormState m FormId
getFormId
inputFile :: forall m input err view ft. (Environment m input, FormInput input, FormError input err, ft ~ FileType input, Monoid ft)
=> (FormId -> view)
-> Form m input err view (FileType input)
inputFile :: (FormId -> view) -> Form m input err view (FileType input)
inputFile = FormState m FormId
-> (FormId -> view) -> Form m input err view (FileType input)
forall (m :: * -> *) ft input err view.
(Monad m, FormInput input, FormError input err,
Environment m input, ft ~ FileType input, Monoid ft) =>
FormState m FormId
-> (FormId -> view) -> Form m input err view (FileType input)
G.inputFile FormState m FormId
forall (m :: * -> *). Monad m => FormState m FormId
getFormId
inputMulti :: forall m input err view a lbl. (FormError input err, FormInput input, Environment m input, Eq a)
=> [(a, lbl)]
-> (input -> Either err [a])
-> (FormId -> [G.Choice lbl a] -> view)
-> (a -> Bool)
-> Form m input err view [a]
inputMulti :: [(a, lbl)]
-> (input -> Either err [a])
-> (FormId -> [Choice lbl a] -> view)
-> (a -> Bool)
-> Form m input err view [a]
inputMulti = FormState m FormId
-> [(a, lbl)]
-> (input -> Either err [a])
-> (FormId -> [Choice lbl a] -> view)
-> (a -> Bool)
-> Form m input err view [a]
forall (m :: * -> *) input err view a lbl.
(FormError input err, FormInput input, Environment m input,
Eq a) =>
FormState m FormId
-> [(a, lbl)]
-> (input -> Either err [a])
-> (FormId -> [Choice lbl a] -> view)
-> (a -> Bool)
-> Form m input err view [a]
G.inputMulti FormState m FormId
forall (m :: * -> *). Monad m => FormState m FormId
getFormId
inputChoice :: forall a m err input lbl view. (FormError input err, FormInput input, Environment m input, Eq a, Monoid view)
=> (a -> Bool)
-> NonEmpty (a, lbl)
-> (input -> Either err a)
-> (FormId -> [G.Choice lbl a] -> view)
-> Form m input err view a
inputChoice :: (a -> Bool)
-> NonEmpty (a, lbl)
-> (input -> Either err a)
-> (FormId -> [Choice lbl a] -> view)
-> Form m input err view a
inputChoice = FormState m FormId
-> (a -> Bool)
-> NonEmpty (a, lbl)
-> (input -> Either err a)
-> (FormId -> [Choice lbl a] -> view)
-> Form m input err view a
forall a (m :: * -> *) err input lbl view.
(FormError input err, FormInput input, Monad m, Eq a, Monoid view,
Environment m input) =>
FormState m FormId
-> (a -> Bool)
-> NonEmpty (a, lbl)
-> (input -> Either err a)
-> (FormId -> [Choice lbl a] -> view)
-> Form m input err view a
G.inputChoice FormState m FormId
forall (m :: * -> *). Monad m => FormState m FormId
getFormId
inputList :: forall m input err a view. (Monad m, FormError input err, Environment m input)
=> (input -> m (Either err [a]))
-> ([view] -> view)
-> [a]
-> view
-> (a -> Form m input err view a)
-> Form m input err view [a]
inputList :: (input -> m (Either err [a]))
-> ([view] -> view)
-> [a]
-> view
-> (a -> Form m input err view a)
-> Form m input err view [a]
inputList = FormState m FormId
-> (input -> m (Either err [a]))
-> ([view] -> view)
-> [a]
-> view
-> (a -> Form m input err view a)
-> Form m input err view [a]
forall (m :: * -> *) input err a view view'.
(Monad m, FormError input err, Environment m input) =>
FormState m FormId
-> (input -> m (Either err [a]))
-> ([view] -> view')
-> [a]
-> view'
-> (a -> Form m input err view a)
-> Form m input err view' [a]
G.inputList FormState m FormId
forall (m :: * -> *). Monad m => FormState m FormId
getFormId
label :: Environment m input
=> (FormId -> view)
-> Form m input err view ()
label :: (FormId -> view) -> Form m input err view ()
label = FormState m FormId -> (FormId -> view) -> Form m input err view ()
forall (m :: * -> *) view input err.
Monad m =>
FormState m FormId -> (FormId -> view) -> Form m input err view ()
G.label FormState m FormId
forall (m :: * -> *). Monad m => FormState m FormId
getFormId
errors :: Environment m input
=> ([err] -> view)
-> Form m input err view ()
errors :: ([err] -> view) -> Form m input err view ()
errors = ([err] -> view) -> Form m input err view ()
forall (m :: * -> *) err view input.
Monad m =>
([err] -> view) -> Form m input err view ()
G.errors
childErrors :: Environment m input
=> ([err] -> view)
-> Form m input err view ()
childErrors :: ([err] -> view) -> Form m input err view ()
childErrors = ([err] -> view) -> Form m input err view ()
forall (m :: * -> *) err view input.
Monad m =>
([err] -> view) -> Form m input err view ()
G.childErrors
withErrors :: Environment m input
=> (view -> [err] -> view)
-> Form m input err view a
-> Form m input err view a
withErrors :: (view -> [err] -> view)
-> Form m input err view a -> Form m input err view a
withErrors = (view -> [err] -> view)
-> Form m input err view a -> Form m input err view a
forall (m :: * -> *) view err input a.
Monad m =>
(view -> [err] -> view)
-> Form m input err view a -> Form m input err view a
G.withErrors