Module

Polyform.Form.Component

#Component

newtype Component m form i o

Tiny wrapper around validation which also carries default "form" value.

Constructors

Instances

#runValidation

runValidation :: forall form i o m. Component m form i o -> (i -> m (V form o))

#fromValidation

fromValidation :: forall a b e m. Monoid e => Validation m e a b -> Component m e a b

#hoistFn

hoistFn :: forall a b e m. Monoid e => Monad m => (a -> b) -> Component m e a b

#hoistFnV

hoistFnV :: forall a b e m. Monoid e => Monad m => (a -> V e b) -> Component m e a b

#hoistFnMV

hoistFnMV :: forall a b e m. Monoid e => Monad m => (a -> m (V e b)) -> Component m e a b

#fromField

fromField :: forall attrs e form m q v. Monad m => ({ value :: V e v | attrs } -> form) -> { value :: V e v | attrs } -> Validation m e q v -> Component m form q v

Simple helper which combines basic pieces into Component:

  • form constructor (I could use Applicative.pure but it seems a bit to heavy constraint ;-))
  • default field value
  • validation

#fromFieldCoerce

fromFieldCoerce :: forall attrs e form m q v v'. Monad m => (v -> v') -> ({ value :: V e v | attrs } -> form) -> { value :: V e v | attrs } -> Validation m e q v -> Component m form q v'

Longer version of previous one which allows coersion of field level value into form level value.

Modules