Module

Formless

Formless is a renderless component to help you build forms in Halogen. This module re-exports all public functions and types from the library, and can be used as the single import for most use cases.

import Formless as F

Re-exports from Formless.Action

#validateAll

validateAll :: forall v. Variant (validateAll :: Unit | v)

Validate all fields in the form, collecting errors

[ HE.onClick \_ -> Just F.validateAll ]

#validate

validate :: forall form v sym us r e i o. IsSymbol sym => Newtype (form Variant U) (Variant us) => Cons sym (U e i o) r us => Proxy sym -> Variant (validate :: form Variant U | v)

Trigger validation on a form field

[ HE.onBlur \_ -> Just $ F.validate _name ]

#submit

submit :: forall v. Variant (submit :: Unit | v)

Submit the form, which will trigger a Submitted result if the form validates successfully.

[ HE.onClick \_ -> Just F.submit ]

#setValidateAll

setValidateAll :: forall form v is' is. Newtype (form Record InputField) (Record is') => HMap WrapField (Record is) (Record is') => Record is -> Variant (setAll :: Tuple (form Record InputField) Boolean | v)

Provide a record of inputs to overwrite all current inputs without resetting the form (as loadForm does), and then validate the entire new set of fields. Similar to calling setValidate on every field in the form.

[ HE.onClick \_ -> Just $ F.setValidateAll
    { name: "Default Name"
    , enabled: false
    }
]

#setValidate

setValidate :: forall form v sym inputs r e i o. IsSymbol sym => Newtype (form Variant InputFunction) (Variant inputs) => Cons sym (InputFunction e i o) r inputs => Proxy sym -> i -> Variant (modifyValidate :: Tuple (Maybe Milliseconds) (form Variant InputFunction) | v)

Set the input value of a form field at the specified label, also triggering validation to run on the field.

[ HE.onValueInput $ Just <<< F.setValidate _name ]

#setAll

setAll :: forall form v is is'. Newtype (form Record InputField) (Record is') => HMap WrapField (Record is) (Record is') => Record is -> Variant (setAll :: Tuple (form Record InputField) Boolean | v)

Provide a record of input fields to overwrite all current inputs. Unlike loadForm, this does not otherwise reset the form as if it were new. Similar to calling set on every field in the form. Does not run validation.

[ HE.onClick \_ -> Just $ F.setAll
    { name: "Default Name"
    , enabled: false
    }
]

#set

set :: forall form v sym inputs r e i o. IsSymbol sym => Newtype (form Variant InputFunction) (Variant inputs) => Cons sym (InputFunction e i o) r inputs => Proxy sym -> i -> Variant (modify :: form Variant InputFunction | v)

Set the input value of a form field at the specified label.

[ HE.onValueInput $ Just <<< F.set _name ]

#resetAll

resetAll :: forall v. Variant (resetAll :: Unit | v)

Reset all fields to their initial values, and reset the form to its initial pristine state, no touched fields.

[ HE.onClick \_ -> Just F.resetAll ]

#reset

reset :: forall form v sym inputs r e i o. IsSymbol sym => Initial i => Newtype (form Variant InputFunction) (Variant inputs) => Cons sym (InputFunction e i o) r inputs => Proxy sym -> Variant (reset :: form Variant InputFunction | v)

Reset the value of the specified form field to its default value according to the Initial type class.

[ HE.onClick \_ -> Just $ F.reset _name ]

#modifyValidateAll

modifyValidateAll :: forall form v ifs' ifs. Newtype (form Record InputFunction) (Record ifs') => HMap WrapField (Record ifs) (Record ifs') => Record ifs -> Variant (modifyAll :: Tuple (form Record InputFunction) Boolean | v)

Provide a record of input functions to modify all current inputs, and then validate all fields. Similar to calling modifyValidate on every field in the form.

[ HE.onClick \_ -> Just $ F.modifyValidateAll
    { name: \str -> "User: " <> str
    , enabled: \bool -> not bool
    }
]

#modifyValidate

modifyValidate :: forall form v sym inputs r e i o. IsSymbol sym => Newtype (form Variant InputFunction) (Variant inputs) => Cons sym (InputFunction e i o) r inputs => Proxy sym -> (i -> i) -> Variant (modifyValidate :: Tuple (Maybe Milliseconds) (form Variant InputFunction) | v)

Modify the input value of a form field at the specified label, also triggering validation to run on the field, with the provided function.

[ HE.onChange \_ -> Just $ F.modifyValidate _enabled not ]

#modifyAll

modifyAll :: forall form v ifs' ifs. Newtype (form Record InputFunction) (Record ifs') => HMap WrapField (Record ifs) (Record ifs') => Record ifs -> Variant (modifyAll :: Tuple (form Record InputFunction) Boolean | v)

Provide a record of input functions to modify all current inputs. Similar to calling modify on every field in the form. Does not run validation.

[ HE.onClick \_ -> Just $ F.modifyAll
    { name: \str -> "User: " <> str
    , enabled: \bool -> not bool
    }
]

#modify

modify :: forall form v sym inputs r e i o. IsSymbol sym => Newtype (form Variant InputFunction) (Variant inputs) => Cons sym (InputFunction e i o) r inputs => Proxy sym -> (i -> i) -> Variant (modify :: form Variant InputFunction | v)

Modify the input value of a form field at the specified label with the provided function.

[ HE.onChange \_ -> Just $ F.modify _enabled not ]

#loadForm

loadForm :: forall form v. form Record InputField -> Variant (loadForm :: form Record InputField | v)

Load a form from a set of existing inputs. Useful for when you need to mount Formless, perform some other actions like request data from the server, and then load an existing set of inputs.

[ HE.onClick \_ -> Just $ F.loadForm $ F.wrapInputFields
    { name: ""
    , enabled: false
    }
]

#injAction

injAction :: forall form act. act -> Action form act

Inject your own action into the Formless component so it can be used in HTML

#asyncSetValidate

asyncSetValidate :: forall form v sym inputs r e i o. IsSymbol sym => Newtype (form Variant InputFunction) (Variant inputs) => Cons sym (InputFunction e i o) r inputs => Milliseconds -> Proxy sym -> i -> Variant (modifyValidate :: Tuple (Maybe Milliseconds) (form Variant InputFunction) | v)

Set the input value of a form field at the specified label, while debouncing validation so that it only runs after the specified amount of time has elapsed since the last modification. Useful when you need to avoid expensive validation but do not want to wait for a blur event to validate.

[ HE.onValueInput $ Just <<< F.asncSetValidate (Milliseconds 300.0) _name ]

#asyncModifyValidate

asyncModifyValidate :: forall form v sym inputs r e i o. IsSymbol sym => Newtype (form Variant InputFunction) (Variant inputs) => Cons sym (InputFunction e i o) r inputs => Milliseconds -> Proxy sym -> (i -> i) -> Variant (modifyValidate :: Tuple (Maybe Milliseconds) (form Variant InputFunction) | v)

Modify the input value of a form field at the specified label, while debouncing validation so that it only runs after the specified amount of time has elapsed since the last modification. Useful when you need to avoid expensive validation but do not want to wait for a blur event to validate.

[ HE.onChange \_ -> Just $ F.asncModifyValidate (Milliseconds 300.0) _enabled not ]

Re-exports from Formless.Class.Initial

#Initial

class Initial v  where

A type class that provides initial values for form fields. While superficially similar to Haskell's Default type class, this class is only meant for the purposes of defining initial form values. If you need a default value for a field in your form, you are better off defining it as a Maybe field and providing a default as part of validation.

In general, if you find yourself reaching for this type class without defining your form as a row and generating your form spec from it, then you are probably not doing what you intend.

Members

Instances

Re-exports from Formless.Component

#raiseResult

raiseResult :: forall form st act slots wrappedOutput output m. Newtype (form Record OutputField) (Record wrappedOutput) => HMap UnwrapField (Record wrappedOutput) (Record output) => Event form st -> HalogenM form st act slots (Record output) m Unit

A convenience function for raising a form's validated and unwrapped outputs as its only message to a parent component. Useful when you only want to be notified with a form's successfully-parsed data. For example:

type User = { name :: String, email :: Email }

newtype UserForm r f = UserForm (r
  ( name :: f Void String String
  , email :: f EmailError String Email
  ))
derive instance newtypeUserForm :: Newtype (UserForm r f) _

-- we only want to handle our `User` type on successful submission; we can
-- use `raiseResult` as our `handleEvent` function to do this conveniently.
formSpec = F.defaultSpec { handleEvent = raiseResult }

-- the parent can now just handle the `User` output
data ParentAction = HandleForm User

type ChildSlots = ( formless :: F.Slot' UserForm User Unit )

#handleQuery

handleQuery :: forall form st query act slots msg m a is ixs ivs fs fxs us vs os ifs ivfs. MonadAff m => RowToList is ixs => RowToList fs fxs => EqRecord ixs is => InputFieldsToFormFields ixs is fs => FormFieldsToInputFields fxs fs is => CountErrors fxs fs => AllTouched fxs fs => SetFormFieldsTouched fxs fs fs => ReplaceFormFieldInputs is fxs fs fs => ModifyAll ifs fxs fs fs => ValidateAll vs fxs fs fs m => FormFieldToMaybeOutput fxs fs os => Newtype (form Record InputField) (Record is) => Newtype (form Record InputFunction) (Record ifs) => Newtype (form Record FormField) (Record fs) => Newtype (form Record OutputField) (Record os) => Newtype (form Record (Validation form m)) (Record vs) => Newtype (form Variant InputField) (Variant ivs) => Newtype (form Variant InputFunction) (Variant ivfs) => Newtype (form Variant U) (Variant us) => Lacks "internal" st => (forall b. query b -> HalogenM form st act slots msg m (Maybe b)) -> (Event form st -> HalogenM form st act slots msg m Unit) -> Query form query slots a -> HalogenM form st act slots msg m (Maybe a)

#handleAction

handleAction :: forall form st act slots msg m is ixs ivs fs fxs us vs os ifs ivfs. MonadAff m => RowToList is ixs => RowToList fs fxs => EqRecord ixs is => InputFieldsToFormFields ixs is fs => FormFieldsToInputFields fxs fs is => CountErrors fxs fs => AllTouched fxs fs => SetFormFieldsTouched fxs fs fs => ReplaceFormFieldInputs is fxs fs fs => ModifyAll ifs fxs fs fs => ValidateAll vs fxs fs fs m => FormFieldToMaybeOutput fxs fs os => Newtype (form Record InputField) (Record is) => Newtype (form Record InputFunction) (Record ifs) => Newtype (form Record FormField) (Record fs) => Newtype (form Record OutputField) (Record os) => Newtype (form Record (Validation form m)) (Record vs) => Newtype (form Variant InputField) (Variant ivs) => Newtype (form Variant InputFunction) (Variant ivfs) => Newtype (form Variant U) (Variant us) => Lacks "internal" st => (act -> HalogenM form st act slots msg m Unit) -> (Event form st -> HalogenM form st act slots msg m Unit) -> Action form act -> HalogenM form st act slots msg m Unit

#defaultSpec

defaultSpec :: forall form st query act slots input msg m. Spec form st query act slots input msg m

The default spec, which can be overridden by whatever functions you need to extend the component. For example:

mySpec = F.defaultSpec { render = myRender }

#component

component :: forall form st query act slots input msg m is ixs ivs fs fxs us vs os ifs ivfs. MonadAff m => RowToList is ixs => RowToList fs fxs => EqRecord ixs is => InputFieldsToFormFields ixs is fs => FormFieldsToInputFields fxs fs is => CountErrors fxs fs => AllTouched fxs fs => SetFormFieldsTouched fxs fs fs => ReplaceFormFieldInputs is fxs fs fs => ModifyAll ifs fxs fs fs => ValidateAll vs fxs fs fs m => FormFieldToMaybeOutput fxs fs os => MakeInputFieldsFromRow ixs is is => Newtype (form Record InputField) (Record is) => Newtype (form Record InputFunction) (Record ifs) => Newtype (form Record FormField) (Record fs) => Newtype (form Record OutputField) (Record os) => Newtype (form Record (Validation form m)) (Record vs) => Newtype (form Variant InputField) (Variant ivs) => Newtype (form Variant InputFunction) (Variant ivfs) => Newtype (form Variant U) (Variant us) => Lacks "validators" st => Lacks "initialInputs" st => Lacks "validity" st => Lacks "dirty" st => Lacks "errors" st => Lacks "submitAttempts" st => Lacks "submitting" st => Lacks "form" st => Lacks "internal" st => (input -> Input form st m) -> Spec form st query act slots input msg m -> Component form query slots input msg m

The Formless component, which takes a spec and provides a running form component from it.

Re-exports from Formless.Data.FormFieldResult

#FormFieldResult

data FormFieldResult error output

A data type which represents the possible output states of the field. Use the helpers in Retrieve to easily manipulate this type.

Constructors

Instances

#toMaybe

toMaybe :: forall e o. FormFieldResult e o -> Maybe o

#fromEither

fromEither :: forall e o. Either e o -> FormFieldResult e o

#_Success

_Success :: forall e o. Prism' (FormFieldResult e o) o

#_Error

_Error :: forall e o. Prism' (FormFieldResult e o) e

Re-exports from Formless.Query

#submitReply

submitReply :: forall form query ps a. (Maybe (form Record OutputField) -> a) -> Query form query ps a

Submit the form, returning the output of validation if successful and Nothing otherwise.

#sendQuery

sendQuery :: forall outS outL inS inL form msg q ps cq cm pps r0 r1 st pmsg act m a. IsSymbol outL => IsSymbol inL => Cons outL (Slot (Query form q ps) msg outS) r0 pps => Cons inL (Slot cq cm inS) r1 ps => Ord outS => Ord inS => Proxy outL -> outS -> Proxy inL -> inS -> cq a -> HalogenM st act pps pmsg m (Maybe a)

When you have specified a child component within Formless and need to query it, you can do so in two ways.

First, you can use H.query as usual within the handleExtraQuery function you provide to Formless as input. You can, for example, write your own query which manages the child component, write it into the render function you supply Formless, and then when that query is triggered, query the child component.

Second, you can use the sendQuery function within your parent component's handleAction or handleQuery functions. Given the slot for Formless, the slot for the child component within Formless, and the query you'd like to send the child component, sendQuery will run through Formless and return the query result to the parent.

For example, this is how you would query a dropdown component being run within a Formless form from the parent component.

-- in the parent component which mounts Formless
handleAction = case _ of
  SendDropdown (dropdownQuery -> do
    result <- F.sendQuery _formless unit _dropdown 10 dropdownQuery

#injQuery

injQuery :: forall form q ps a. Functor q => q a -> Query form q ps a

Inject your own query into the Formless component. You will need to derive a Functor instance for your query type.

data MyQuery a = DoSomething a
derive instance functorMyQuery :: Functor MyQuery

#asQuery

asQuery :: forall form q ps. Variant (PublicAction form) -> Query form q ps Unit

Convert a Formless public action to an action-style query. Any action from Formless.Action will work, but no others.

Re-exports from Formless.Retrieve

#GetTouchedField

data GetTouchedField

Data constructor for the getTouchedField function

Constructors

Instances

#GetResultField

data GetResultField

Data constructor for the getResultField function

Constructors

Instances

#GetOutput

data GetOutput

Data constructor for the getOutput function

Constructors

Instances

#GetInputField

data GetInputField

Data constructor for the getInputField function

Constructors

Instances

#GetError

data GetError

Data constructor for the getError function

Constructors

Instances

#GetAll

type GetAll f = forall form r0 r1. HMap f r0 r1 => Newtype (form Record FormField) r0 => form Record FormField -> r1

A type representing retrieving all of a particular field with the field's constructor name. For internal use.

#FormFieldLens

type FormFieldLens e i o x = forall sym form fields t0. IsSymbol sym => Newtype (form Record FormField) (Record fields) => Cons sym (FormField e i o) t0 fields => Proxy sym -> Lens' (form Record FormField) x

A type representing a lens onto part of a form field

#FormFieldGet

type FormFieldGet e i o x = forall sym form fields t0. IsSymbol sym => Newtype (form Record FormField) (Record fields) => Cons sym (FormField e i o) t0 fields => Proxy sym -> form Record FormField -> x

A type representing a function to produce a value from a record of form fields given a particular symbol. The result of view from Data.Lens applied with a particular lens to the form.

#getTouchedAll

getTouchedAll :: GetAll GetTouchedField

Get the form as a record where all fields are only the touched value

#getTouched

getTouched :: forall e i o. FormFieldGet e i o Boolean

Given a form, get the touched field at the specified symbol

#getResultAll

getResultAll :: GetAll GetResultField

Get the form as a record where all fields are only the result value

#getResult

getResult :: forall e i o. FormFieldGet e i o (FormFieldResult e o)

Given a form, get the result at the specified symbol

#getOutputAll

getOutputAll :: GetAll GetOutput

Get the form as a record where all fields are only the output value

#getOutput

getOutput :: forall e i o. FormFieldGet e i o (Maybe o)

Given a form, get the output (if it exists) at the specified symbol

#getInputAll

getInputAll :: GetAll GetInputField

Get the form as a record where all fields are only the input value

#getInput

getInput :: forall e i o. FormFieldGet e i o i

Given a form, get the input at the specified symbol

#getField

getField :: forall e i o. FormFieldGet e i o (Record (FormFieldRow e i o))

Given a form, get the field at the specified symbol

#getErrorAll

getErrorAll :: GetAll GetError

Get the form as a record where all fields are only the error value

#getError

getError :: forall e i o. FormFieldGet e i o (Maybe e)

Given a form, get the error (if it exists) at the specified symbol

#_FieldTouched

_FieldTouched :: forall e i o. FormFieldLens e i o Boolean

A lens to operate on the 'touched' field at a given symbol in your form

#_FieldResult

_FieldResult :: forall e i o. FormFieldLens e i o (FormFieldResult e o)

A lens to operate on the 'result' field at a given symbol in your form

#_FieldOutput

_FieldOutput :: forall sym form fields t0 e i o. IsSymbol sym => Newtype (form Record FormField) (Record fields) => Cons sym (FormField e i o) t0 fields => Proxy sym -> Traversal' (form Record FormField) o

A traversal to operate on the possible output inside the 'result' field at a given symbol in your form

#_FieldInput

_FieldInput :: forall e i o. FormFieldLens e i o i

A lens to operate on the input at a given symbol in your form

#_FieldError

_FieldError :: forall sym form fields t0 e i o. IsSymbol sym => Newtype (form Record FormField) (Record fields) => Cons sym (FormField e i o) t0 fields => Proxy sym -> Traversal' (form Record FormField) e

A traversal to operate on the possible error inside the 'result' field at a given symbol in your form

#_Field

_Field :: forall e i o. FormFieldLens e i o (Record (FormFieldRow e i o))

A lens to operate on the field at a given symbol in your form

Re-exports from Formless.Transform.Record

#WrapField

data WrapField

Wrap every field in a record with a particular newtype

Constructors

Instances

#UnwrapField

data UnwrapField

Unwrap every newtype in a record filled with newtypes

Constructors

Instances

#wrapRecord

wrapRecord :: forall r0 r1. HMap WrapField r0 r1 => r0 -> r1

#wrapInputFunctions

wrapInputFunctions :: forall form ifs ifs'. Newtype (form Record InputFunction) (Record ifs') => HMap WrapField (Record ifs) (Record ifs') => Record ifs -> form Record InputFunction

Provided a record, where each field in the record contains a function from input -> input, wraps each function in the InputField type for compatibility with Formless

#wrapInputFields

wrapInputFields :: forall form is is'. Newtype (form Record InputField) (Record is') => HMap WrapField (Record is) (Record is') => Record is -> form Record InputField

Provided a record, where each field in the record contains a value of type input, wraps each value in the InputField type for compatibility with Formless

#unwrapRecord

unwrapRecord :: forall r0 r1. HMap UnwrapField r0 r1 => r0 -> r1

#unwrapOutputFields

unwrapOutputFields :: forall form os os'. Newtype (form Record OutputField) (Record os) => HMap UnwrapField (Record os) (Record os') => form Record OutputField -> Record os'

Provided your form type containing a record of only valid outputs from the result of validation, unwraps the form and every value in the record to provide a record of only the output values.

Re-exports from Formless.Transform.Row

#SProxies

type SProxies form = forall xs row inputs. RowToList inputs xs => Newtype (form Record InputField) (Record inputs) => MakeSProxies xs row => Record row

A type to collect constraints necessary to apply to prove that a record of SProxies is compatible with your form type.

#MakeInputFieldsFromRow

class MakeInputFieldsFromRow (xs :: RowList Type) (row :: Row Type) (to :: Row Type) | xs -> to where

The class that provides the Builder implementation to efficiently transform a row into a proper InputFields by wrapping it in newtypes and supplying initial values

Members

Instances

#MakeSProxies

class MakeSProxies (xs :: RowList Type) (to :: Row Type) | xs -> to where

The class used to build up a new record of symbol proxies from an input row list.

Members

Instances

#mkSProxies

mkSProxies :: forall form xs inputs row. RowToList inputs xs => Newtype (form Record InputField) (Record inputs) => MakeSProxies xs row => Proxy form -> Record row

A helper function to produce a record of SProxies given a form spec, to save you the boilerplate of writing them all out.

#mkInputFields

mkInputFields :: forall xs form inputs. RowToList inputs xs => Newtype (form Record InputField) (Record inputs) => MakeInputFieldsFromRow xs inputs inputs => form Record InputField

A function to transform a row of labels into a InputFields. This allows you to go directly from a custom form newtype to an inputs record without having to fill in any values. Requires that all members have an instance of the Initial type class (all monoidal values do by default, along with some other primitives).

Re-exports from Formless.Types.Component

#ValidStatus

data ValidStatus

A type to represent validation status

Constructors

Instances

#StateRow

type StateRow form st = (dirty :: Boolean, errors :: Int, form :: form Record FormField, submitAttempts :: Int, submitting :: Boolean, validity :: ValidStatus | st)

The component's public state, as an extensible row

#State'

type State' form m = State form () m

A simple state type when the component does not need extension

#State

type State form st m = Record (StateRow form (internal :: InternalState form m | st))

The component local state

#Spec'

type Spec' form msg input m = Spec form () (Const Void) Void () input msg m

A simplified type when the component has only a form spec, some output, and runs in some monad m

#Spec

type Spec form st query act slots input msg m = { finalize :: Maybe act, handleAction :: act -> HalogenM form st act slots msg m Unit, handleEvent :: Event form st -> HalogenM form st act slots msg m Unit, handleQuery :: forall a. query a -> HalogenM form st act slots msg m (Maybe a), initialize :: Maybe act, receive :: input -> Maybe act, render :: PublicState form st -> ComponentHTML form act slots m }

A type representing the various functions that can be provided to extend the Formless component. Usually only the render function is required, but you may also provide others. For example, if you have child components, you can tell Formless how to manage those child components by adding a handler action and handleAction case.

#Slot'

type Slot' form msg = Slot (Query' form) msg

A simple Slot type when the component does not need extension, besides a custom output message

#Slot

type Slot form query slots msg = Slot (Query form query slots) msg

A slot type that can be used in the ChildSlots definition for your parent component

#QueryF

data QueryF form slots a

The internals of the public component query type. Many of these are shared with actions of the same name so they can be used in rendering. See Formless.Action and Formless.Query for more.

Constructors

Instances

#Query'

type Query' form = Query form (Const Void) ()

A simple query type when the component does not need extension

#Query

type Query form query slots = VariantF (query :: QueryF form slots, userQuery :: query)

The component query type, which you can freely extend with your own queries using injQuery from Formless.Query.

#PublicState

type PublicState form st = Record (StateRow form st)

The component's public state

#PublicAction

type PublicAction form = (loadForm :: form Record InputField, modify :: form Variant InputFunction, modifyAll :: Tuple (form Record InputFunction) Boolean, modifyValidate :: Tuple (Maybe Milliseconds) (form Variant InputFunction), reset :: form Variant InputFunction, resetAll :: Unit, setAll :: Tuple (form Record InputField) Boolean, submit :: Unit, validate :: form Variant U, validateAll :: Unit)

#InternalState

newtype InternalState form m

A newtype to make easier type errors for end users to read by hiding internal fields

Constructors

Instances

#InternalAction

type InternalAction act r = (initialize :: Maybe act, syncFormData :: Unit | r)

#Input'

type Input' form m = Input form () m

A simple Input type when the component does not need extension

#Input

type Input form st m = { initialInputs :: Maybe (form Record InputField), validators :: form Record (Validation form m) | st }

The component's input type. If you provide Nothing as your initialInputs then the form will fill in values based on the Initial type class for the field's input type. Otherwise, the form will contain the values you provide.

Validators can be created using the Formless.Validation module.

#HalogenM'

type HalogenM' form msg m = HalogenM form () Void () msg m

A simple component eval type when the component does not need extension

#HalogenM

type HalogenM form st act slots msg m = HalogenM (State form st m) (Action form act) slots msg m

The component's eval type

#Event'

type Event' form = Event form ()

#Event

data Event form st

The component tries to require as few messages to be handled as possible. You can always use the *Reply variants of queries to perform actions and receive a result out the other end, or extend these messages.

Constructors

#Debouncer

type Debouncer = { fiber :: Fiber Unit, forkId :: ForkId, var :: AVar Unit }

A type to represent a running debouncer

#ComponentHTML'

type ComponentHTML' form m = ComponentHTML form Void () m

A simple component HTML type when the component does not need extension

#ComponentHTML

type ComponentHTML form act slots m = ComponentHTML (Action form act) slots m

The component's HTML type, the result of the render function.

#Component'

type Component' form input m = Component form (Const Void) () input Void m

A simple component type when the component does not need extension

#Component

type Component form query slots input msg m = Component (Query form query slots) input msg m

The component type

#Action'

type Action' form = Action form Void

#Action

type Action form act = Variant (userAction :: act | (InternalAction act) + (PublicAction form))

The component action type. While actions are typically considered internal to a component, in Formless you write the render function and will need to be able to use these directly. Many of these are shared with queries of the same name so they can be used either as queries or as actions. See Formless.Action and Formless.Query.

You can freely extend this type with your own actions using injAction.

#_formless

_formless :: Proxy @Symbol "formless"

A convenience export of formless as a symbol for use when mounting Formless as a child component

type ChildSlots = (formless :: F.Slot' Form FormResult)
HH.slot F._formless unit (F.component spec) input handler

Re-exports from Formless.Types.Form

#U

data U e i o

Constructors

#OutputType

type OutputType error input output = output

#OutputField

newtype OutputField error input output

Constructors

Instances

#InputType

type InputType error input output = input

#InputFunction

newtype InputFunction error input output

Constructors

Instances

#InputField

newtype InputField error input output

Constructors

Instances

#FormFieldRow

type FormFieldRow error input output = (input :: input, result :: FormFieldResult error output, touched :: Boolean)

The row used for the FormField newtype and in lens type signatures

#FormField

newtype FormField e i o

The type that we need to record state across the form

Constructors

Instances

#ErrorType

type ErrorType error input output = error

Re-exports from Formless.Validation

#Validation

newtype Validation form m error input output

A wrapper to represent the validation function on a form field, which can itself take the form state as its first argument. Inspired in some parts by the Validation type from purescript-polyform by @paluh.

Constructors

Instances

#EmptyValidators

data EmptyValidators

The data type used for the noValidation function's heterogenous instance

Constructors

Instances

#runValidation

runValidation :: forall form m e i o. Monad m => Validation form m e i o -> form Record FormField -> i -> m (Either e o)

A more verbose but clearer function for running a validation function on its inputs

#noValidators

noValidators :: forall form fields m vs xs. Monad m => RowToList fields xs => Newtype (form Record (Validation form m)) (Record vs) => Newtype (form Record InputField) (Record fields) => MapRecordWithIndex xs (ConstMapping EmptyValidators) fields vs => form Record InputField -> form Record (Validation form m)

A function to create a record of validators that simply pass through all inputs for when no validation is needed. Provide this as your validators function.

#noValidation

noValidation :: forall form m e i. Monad m => Validation form m e i i

A validation function which simply passes through its input value as its output value. Use on individual fields which do not need any validation.

#hoistFn_

hoistFn_ :: forall form m e i o. Monad m => (i -> o) -> Validation form m e i o

Turn a function from (i -> o) into a proper Validation

#hoistFnME_

hoistFnME_ :: forall form m e i o. Monad m => (i -> m (Either e o)) -> Validation form m e i o

Turn a function from (i -> m (Either e o)) into a proper Validation

#hoistFnME

hoistFnME :: forall form m e i o. Monad m => (form Record FormField -> i -> m (Either e o)) -> Validation form m e i o

Turn a function from (form Record FormField -> i -> m (Either e o)) into a proper Validation

#hoistFnE_

hoistFnE_ :: forall form m e i o. Monad m => (i -> Either e o) -> Validation form m e i o

Turn a function from (i -> Either e o) into a proper Validation

#hoistFnE

hoistFnE :: forall form m e i o. Monad m => (form Record FormField -> i -> Either e o) -> Validation form m e i o

Turn a function from (form Record FormField -> i -> Either e o) into a proper Validation

#hoistFn

hoistFn :: forall form m e i o. Monad m => (form Record FormField -> i -> o) -> Validation form m e i o

Turn a function from (form Record FormField -> i -> o) into a proper Validation

Modules