Safe Haskell | None |
---|---|
Language | Haskell2010 |
- type Widget a = TransIO a
- runBody :: Widget a -> IO (Maybe a)
- addHeader :: Perch -> IO ()
- render :: TransIO a -> TransIO a
- runWidget' :: Widget b -> Elem -> TransIO b
- addSData :: (MonadState EventF m, Typeable a, Monoid a) => a -> m ()
- module Control.Applicative
- (<**) :: TransIO a -> TransIO b -> TransIO a
- validate :: Widget a -> (a -> StateIO (Maybe Perch)) -> TransIO a
- (<<<) :: (Perch -> Perch) -> TransIO a -> TransIO a
- (<<) :: (Perch -> Perch) -> Perch -> Perch
- (<++) :: TransIO a -> Perch -> TransIO a
- (++>) :: Perch -> TransIO a -> TransIO a
- (<!) :: TransIO x -> Attribs -> TransIO x
- wcallback :: Widget a -> (a -> Widget b) -> Widget b
- option :: (Typeable b, Show b) => b -> String -> TransientIO b
- wprint :: ToElem a => a -> Widget ()
- getString :: Maybe String -> TransIO String
- inputString :: Maybe String -> TransIO String
- getInteger :: Maybe Integer -> TransIO Integer
- inputInteger :: Maybe Integer -> TransIO Integer
- getInt :: Maybe Int -> TransIO Int
- inputInt :: Maybe Int -> TransIO Int
- inputFloat :: Maybe Float -> TransIO Float
- inputDouble :: Maybe Double -> TransIO Double
- getPassword :: TransIO String
- inputPassword :: TransIO String
- setRadio :: (Typeable a, Eq a, Show a) => a -> TransIO (Radio a)
- setRadioActive :: (Typeable a, Eq a, Show a) => a -> Widget (Radio a)
- getRadio :: Monoid a => [TransIO (Radio a)] -> TransIO a
- setCheckBox :: (Typeable a, Show a) => Bool -> a -> TransIO (CheckBoxes a)
- getCheckBoxes :: Show a => TransIO (CheckBoxes a) -> TransIO [a]
- getTextBox :: (Typeable a, Show a, Read a) => Maybe a -> TransIO a
- getMultilineText :: JSString -> TransIO String
- textArea :: JSString -> TransIO String
- getBool :: Bool -> String -> String -> TransIO Bool
- getSelect :: (Typeable a, Read a, Show a) => TransIO (MFOption a) -> TransIO a
- setOption :: (Show a, Eq a, Typeable a) => a -> Perch -> TransIO (MFOption a)
- setSelectedOption :: (Show a, Eq a, Typeable a) => a -> Perch -> TransIO (MFOption a)
- wlabel :: Perch -> TransIO a -> TransIO a
- resetButton :: JSString -> TransIO ()
- inputReset :: JSString -> TransIO ()
- submitButton :: (Read a, Show a, Typeable a) => a -> TransIO a
- inputSubmit :: (Read a, Show a, Typeable a) => a -> TransIO a
- wbutton :: a -> JSString -> Widget a
- wlink :: (Show a, Typeable a) => a -> Perch -> Widget a
- noWidget :: TransIO a
- wraw :: Perch -> Widget ()
- rawHtml :: Perch -> Widget ()
- isEmpty :: Widget a -> Widget Bool
- data BrowserEvent
- at :: JSString -> UpdateMethod -> Widget a -> Widget a
- data UpdateMethod
- resetEventData :: TransIO ()
- getEventData :: TransIO EventData
- setEventData :: EventData -> TransIO ()
- class IsEvent a where
- data EventData = EventData {}
- data EvData
- raiseEvent :: IsEvent event => Widget a -> event -> Widget a
- fire :: IsEvent event => Widget a -> event -> Widget a
- wake :: IsEvent event => Widget a -> event -> Widget a
- pass :: IsEvent event => Perch -> event -> Widget EventData
- continueIf :: Bool -> a -> Widget a
- module GHCJS.Perch
- getNextId :: MonadState EventF m => m JSString
- genNewId :: StateIO JSString
- continuePerch :: Widget a -> ElemID -> Widget a
- getParam :: (Typeable a, Show a, Read a) => Maybe JSString -> JSString -> Maybe a -> TransIO a
- getCont :: TransIO EventF
- runCont :: EventF -> StateIO (Maybe a)
- class (Monoid view, Typeable view) => FormInput view where
- type ElemID = JSString
- elemById :: MonadIO m => JSString -> m (Maybe Elem)
- withElem :: ElemID -> (Elem -> IO a) -> IO a
- getProp :: Elem -> JSString -> IO JSString
- setProp :: Elem -> JSString -> JSString -> IO ()
- alert :: JSString -> IO ()
- fromJSString :: (Typeable a, Read a) => JSString -> a
- toJSString :: (Typeable * a, Show a) => a -> t
- getValue :: MonadIO m => Elem -> m (Maybe String)
Documentation
running it
runBody :: Widget a -> IO (Maybe a) Source #
run the widget as the body of the HTML. It adds the rendering to the body of the document.
render :: TransIO a -> TransIO a Source #
executes the computation and add the effect of "hanging" the generated rendering from the one generated by the
previous render
sentence, or from the body of the document, if there isn't any. If an event happens within
the render
parameter, it deletes the rendering of all subsequent ones.
so that the sucessive sequence of render
in the code will reconstruct them again.
However the rendering of elements combined with <|>
or <>
or <*>
are independent.
This allows for full dynamic and composable client-side Web apps.
re-exported
module Control.Applicative
widget combinators and modifiers
(<**) :: TransIO a -> TransIO b -> TransIO a infixr 1 #
forces the execution of the second operand even if the first stop. It does not execute the second operand as result of internal events occuring in the first operand. Return the first result
validate :: Widget a -> (a -> StateIO (Maybe Perch)) -> TransIO a Source #
Validates a form or widget result against a validating procedure
getOdd= getInt Nothing validate
(x -> return $ if mod x 2==0 then Nothing else Just "only odd numbers, please")
(<<<) :: (Perch -> Perch) -> TransIO a -> TransIO a infixr 5 Source #
Enclose Widgets within some formating.
view
is intended to be instantiated to a particular format
NOTE: It has a infix priority : infixr 5
less than the one of ++>
and <++
of the operators, so use parentheses when appropriate,
unless the we want to enclose all the widgets in the right side.
Most of the type errors in the DSL are due to the low priority of this operator.
(<<) :: (Perch -> Perch) -> Perch -> Perch infixr 7 Source #
A parameter application with lower priority than ($) and direct function application
(<++) :: TransIO a -> Perch -> TransIO a infixr 6 Source #
Append formatting code to a widget
getString "hi" <++ H1 << "hi there"
It has a infix prority: infixr 6
higuer that <<<
and most other operators
(++>) :: Perch -> TransIO a -> TransIO a infixr 6 Source #
Prepend formatting code to a widget
bold "enter name" ++ getString Nothing
It has a infix prority: infixr 6
higher that <<<
and most other operators
(<!) :: TransIO x -> Attribs -> TransIO x infixl 8 Source #
Add attributes to the topmost tag of a widget
it has a fixity infix 8
wcallback :: Widget a -> (a -> Widget b) -> Widget b Source #
It is a callback in the view monad. The rendering of the second parameter substitutes the rendering of the first paramenter when the latter validates without afecting the rendering of other widgets. This allow the simultaneous execution of different dynamic behaviours in different page locations at the same page.
basic widgets
option :: (Typeable b, Show b) => b -> String -> TransientIO b Source #
use this instead of option
when runing in the browser
wprint :: ToElem a => a -> Widget () Source #
show something enclosed in the pre tag, so ASCII formatting chars are honored
getString :: Maybe String -> TransIO String Source #
Display a text box and return a non empty String
getInteger :: Maybe Integer -> TransIO Integer Source #
Display a text box and return an Integer (if the value entered is not an Integer, fails the validation)
getInt :: Maybe Int -> TransIO Int Source #
Display a text box and return a Int (if the value entered is not an Int, fails the validation)
getPassword :: TransIO String Source #
Display a password box
setRadio :: (Typeable a, Eq a, Show a) => a -> TransIO (Radio a) Source #
Implement a radio button the parameter is the name of the radio group
getRadio :: Monoid a => [TransIO (Radio a)] -> TransIO a Source #
encloses a set of Radio boxes. Return the option selected
setCheckBox :: (Typeable a, Show a) => Bool -> a -> TransIO (CheckBoxes a) Source #
Display a text box and return the value entered if it is readable( Otherwise, fail the validation)
getMultilineText :: JSString -> TransIO String Source #
Display a multiline text box and return its content
getSelect :: (Typeable a, Read a, Show a) => TransIO (MFOption a) -> TransIO a Source #
Display a dropdown box with the options in the first parameter is optionally selected . It returns the selected option.
setOption :: (Show a, Eq a, Typeable a) => a -> Perch -> TransIO (MFOption a) Source #
Set the option for getSelect. Options are concatenated with <|>
setSelectedOption :: (Show a, Eq a, Typeable a) => a -> Perch -> TransIO (MFOption a) Source #
Set the selected option for getSelect. Options are concatenated with <|>
resetButton :: JSString -> TransIO () Source #
inputReset :: JSString -> TransIO () Source #
wbutton :: a -> JSString -> Widget a Source #
active button. When clicked, return the first parameter
wlink :: (Show a, Typeable a) => a -> Perch -> Widget a Source #
Present a link. Return the first parameter when clicked
noWidget :: TransIO a Source #
Empty widget that does not validate. May be used as "empty boxes" inside larger widgets.
It returns a non valid value.
wraw :: Perch -> Widget () Source #
Render raw view formatting. It is useful for displaying information.
Event
data BrowserEvent Source #
out of flow updates
at :: JSString -> UpdateMethod -> Widget a -> Widget a Source #
Run the widget as the content of the element with the given id. The content can be appended, prepended to the previous content or it can be the only content depending on the update method.
reactive and events
resetEventData :: TransIO () Source #
setEventData :: EventData -> TransIO () Source #
raiseEvent :: IsEvent event => Widget a -> event -> Widget a Source #
triggers the event that happens in a widget. The effects are the following:
1)The event reexecutes the monadic sentence where the widget is, (with no re-rendering)
2) with the result of this reevaluaution of 1), the rest of the monadic computation is executed
3) update the DOM tree with the rendering generated by the reevaluation of 2).
As usual, If one step of the monadic computation return empty
(stop
), the reevaluation finish
So the effect of an event can be restricted as much as you may need.
The part of the monadic expression that is before the event is not evaluated and his rendering is untouched.
(but, at any moment, you can choose the element to be updated in the page using at
)
wake :: IsEvent event => Widget a -> event -> Widget a Source #
A shorter and smoother synonym for raiseEvent
pass :: IsEvent event => Perch -> event -> Widget EventData Source #
pass trough only if the event is fired in this DOM element. Otherwise, if the code is executing from a previous event, the computation will stop
continueIf :: Bool -> a -> Widget a Source #
return empty and the monadic computation stop if the condition is false. If true, return the second parameter.
Perch is reexported
module GHCJS.Perch
low level and internals
getNextId :: MonadState EventF m => m JSString Source #
get the next ideitifier that will be created by genNewId
genNewId :: StateIO JSString Source #
Generate a new string. Useful for creating tag identifiers and other attributes.
if the page is refreshed, the identifiers generated are the same.
continuePerch :: Widget a -> ElemID -> Widget a Source #
when creating a complex widget with many tags, this call indentifies which tag will receive the attributes of the (!) operator.
getParam :: (Typeable a, Show a, Read a) => Maybe JSString -> JSString -> Maybe a -> TransIO a Source #
get the continuation context: closure, continuation, state, child threads etc
runCont :: EventF -> StateIO (Maybe a) #
run the closure and the continuation using the state data of the calling thread
class (Monoid view, Typeable view) => FormInput view where Source #
Minimal interface for defining the basic form and link elements. The core of MFlow is agnostic
about the rendering package used. Every formatting (either HTML or not) used with MFlow must have an
instance of this class.
See "MFlow.Forms.Blaze.Html for the instance for blaze-html" MFlow.Forms.XHtml for the instance
for Text.XHtml
and MFlow.Forms.HSP for the instance for Haskell Server Pages.
fromStr, fromStrNoEncode, ftag, inred, flink, finput, ftextarea, fselect, foption, formAction, attrs
fromStr :: JSString -> view Source #
fromStrNoEncode :: String -> view Source #
ftag :: JSString -> view -> view Source #
inred :: view -> view Source #
flink :: JSString -> view -> view Source #
flink1 :: JSString -> view Source #
finput :: Name -> Type -> Value -> Checked -> OnClick1 -> view Source #
ftextarea :: JSString -> JSString -> view Source #
fselect :: JSString -> view -> view Source #
foption :: JSString -> view -> Bool -> view Source #
foption1 :: JSString -> Bool -> view Source #
formAction :: JSString -> JSString -> view -> view Source #
fromJSString :: (Typeable a, Read a) => JSString -> a Source #
Orphan instances
Attributable (Widget a) Source # | |