Module

Polyform.Form.Component

Package
purescript-polyform
Repository
paluh/purescript-polyform

#Component Source

newtype Component m form i o

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

Constructors

Instances

#runValidation Source

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

#fromValidation Source

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

#hoistFn Source

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

#hoistFnV Source

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

#hoistFnMV Source

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

#fromField Source

fromField :: forall v q m form e attrs. 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 Source

fromFieldCoerce :: forall v' v q m form e attrs. 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.