{-# 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 = G.input 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 = G.inputMaybe getFormId
inputNoData :: (Environment m input)
=> (FormId -> view)
-> Form m input err view ()
inputNoData = G.inputNoData 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 = G.inputFile 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 = G.inputMulti 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 = G.inputChoice 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 = G.inputList getFormId
label :: Environment m input
=> (FormId -> view)
-> Form m input err view ()
label = G.label getFormId
errors :: Environment m input
=> ([err] -> view)
-> Form m input err view ()
errors = G.errors
childErrors :: Environment m input
=> ([err] -> view)
-> Form m input err view ()
childErrors = G.childErrors
withErrors :: Environment m input
=> (view -> [err] -> view)
-> Form m input err view a
-> Form m input err view a
withErrors = G.withErrors