miso
Copyright(C) 2016-2025 David M. Johnson
LicenseBSD3-style (see the file LICENSE)
MaintainerDavid M. Johnson <code@dmj.io>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Miso.Types

Description

 
Synopsis

Types

data Component (name :: Symbol) model action Source #

Application entry point

Constructors

Component 

Fields

  • model :: model

    initial model

  • update :: action -> Effect model action

    Function to update model, optionally providing effects.

  • view :: model -> View action

    Function to draw View

  • subs :: [Sub action]

    List of subscriptions to run during application lifetime

  • events :: Events

    List of delegated events that the body element will listen for. You can start with defaultEvents and modify as needed.

  • styles :: [CSS]

    List of CSS styles expressed as either a URL (Href) or as Style text. These styles are appended dynamically to the head section of your HTML page before the initial draw on body occurs.

    Since: 1.9.0.0

  • initialAction :: Maybe action

    Initial action that is run after the application has loaded, optional

    Since: 1.9.0.0

  • mountPoint :: Maybe MountPoint

    Id of the root element for DOM diff. If Nothing is provided, the entire document body is used as a mount point.

  • logLevel :: LogLevel

    Debugging for prerendering and event delegation

Instances

Instances details
ToView (Component name model action) Source # 
Instance details

Defined in Miso.Types

Associated Types

type ToViewAction (Component name model action) 
Instance details

Defined in Miso.Types

type ToViewAction (Component name model action) = action

Methods

toView :: Component name model action -> View (ToViewAction (Component name model action)) Source #

type ToViewAction (Component name model action) Source # 
Instance details

Defined in Miso.Types

type ToViewAction (Component name model action) = action

data SomeComponent Source #

Existential wrapper used to allow the nesting of Component in Component

Constructors

Eq model => SomeComponent (Component name model action) 

type Dynamic = "" Source #

Type synonym for Dynamically constructed Component sampleComponent :: Component Dynamic Model Action

data View action Source #

Core type for constructing a virtual DOM in Haskell

Instances

Instances details
Functor View Source # 
Instance details

Defined in Miso.Types

Methods

fmap :: (a -> b) -> View a -> View b #

(<$) :: a -> View b -> View a #

HasRouter (View a :: Type) Source #

View

Instance details

Defined in Miso.Router

Methods

mkRouter :: Proxy (View a) -> Proxy a0 -> RouteT (View a) a0 -> Router a0 Source #

HasLink (View a :: Type) Source #

For constructing type-safe links

Instance details

Defined in Miso.Types

Methods

toLink :: (Link -> a0) -> Proxy (View a) -> Link -> MkLink (View a) a0 Source #

IsString (View a) Source #

IsString instance

Instance details

Defined in Miso.Types

Methods

fromString :: String -> View a #

ToHtml (View a) Source #

Render a View to a L.ByteString

Instance details

Defined in Miso.Render

Methods

toHtml :: View a -> ByteString Source #

ToHtml [View a] Source #

Render a [View] to a L.ByteString

Instance details

Defined in Miso.Render

Methods

toHtml :: [View a] -> ByteString Source #

ToView (View action) Source # 
Instance details

Defined in Miso.Types

Associated Types

type ToViewAction (View action) 
Instance details

Defined in Miso.Types

type ToViewAction (View action) = action

Methods

toView :: View action -> View (ToViewAction (View action)) Source #

type RouteT (View a :: Type) x Source # 
Instance details

Defined in Miso.Router

type RouteT (View a :: Type) x = x
type MkLink (View a :: Type) b Source # 
Instance details

Defined in Miso.Types

type MkLink (View a :: Type) b = b
type ToViewAction (View action) Source # 
Instance details

Defined in Miso.Types

type ToViewAction (View action) = action

newtype Key Source #

A unique key for a dom node.

This key is only used to speed up diffing the children of a DOM node, the actual content is not important. The keys of the children of a given DOM node must be unique. Failure to satisfy this invariant gives undefined behavior at runtime.

Constructors

Key MisoString 

Instances

Instances details
ToJSON Key Source # 
Instance details

Defined in Miso.Types

IsString Key Source # 
Instance details

Defined in Miso.Types

Methods

fromString :: String -> Key #

Show Key Source # 
Instance details

Defined in Miso.Types

Methods

showsPrec :: Int -> Key -> ShowS #

show :: Key -> String #

showList :: [Key] -> ShowS #

Eq Key Source # 
Instance details

Defined in Miso.Types

Methods

(==) :: Key -> Key -> Bool #

(/=) :: Key -> Key -> Bool #

ToJSVal Key Source #

ToJSVal instance for Key

Instance details

Defined in Miso.Types

ToKey Key Source #

Identity instance

Instance details

Defined in Miso.Types

Methods

toKey :: Key -> Key Source #

data Attribute action Source #

Attribute of a vnode in a View.

The Sink callback can be used to dispatch actions which are fed back to the update function. This is especially useful for event handlers like the onclick attribute. The second argument represents the vnode the attribute is attached to.

Instances

Instances details
Functor Attribute Source # 
Instance details

Defined in Miso.Types

Methods

fmap :: (a -> b) -> Attribute a -> Attribute b #

(<$) :: a -> Attribute b -> Attribute a #

data NS Source #

Namespace of DOM elements.

Constructors

HTML

HTML Namespace

SVG

SVG Namespace

MATHML

MATHML Namespace

Instances

Instances details
Show NS Source # 
Instance details

Defined in Miso.Types

Methods

showsPrec :: Int -> NS -> ShowS #

show :: NS -> String #

showList :: [NS] -> ShowS #

Eq NS Source # 
Instance details

Defined in Miso.Types

Methods

(==) :: NS -> NS -> Bool #

(/=) :: NS -> NS -> Bool #

ToJSVal NS Source # 
Instance details

Defined in Miso.Types

data CSS Source #

Allow users to express CSS and append it to head before the first draw

Href "http://domain.com/style.css

Constructors

Href MisoString

Href is a URL meant to link to hosted CSS

Style MisoString

Style is meant to be raw CSS in a style_ tag

Instances

Instances details
Show CSS Source # 
Instance details

Defined in Miso.Types

Methods

showsPrec :: Int -> CSS -> ShowS #

show :: CSS -> String #

showList :: [CSS] -> ShowS #

Eq CSS Source # 
Instance details

Defined in Miso.Types

Methods

(==) :: CSS -> CSS -> Bool #

(/=) :: CSS -> CSS -> Bool #

data LogLevel Source #

Optional Logging for debugging miso internals (useful to see if prerendering is successful)

Constructors

Off

No debug logging, the default value used in defaultComponent

DebugHydrate

Will warn if the structure or properties of the DOM vs. Virtual DOM differ during prerendering.

DebugEvents

Will warn if an event cannot be routed to the Haskell event handler that raised it. Also will warn if an event handler is being used, yet it's not being listened for by the event delegator mount point.

DebugNotify

Will warn if a Component can't be found when using notify or notify'

DebugAll

Logs on all of the above

Instances

Instances details
Show LogLevel Source # 
Instance details

Defined in Miso.Types

Eq LogLevel Source # 
Instance details

Defined in Miso.Types

type MountPoint = MisoString Source #

mountPoint for Component, e.g "body"

Classes

class ToView a where Source #

Convenience class for using View

Associated Types

type ToViewAction a Source #

Methods

toView :: a -> View (ToViewAction a) Source #

Instances

Instances details
ToView (View action) Source # 
Instance details

Defined in Miso.Types

Associated Types

type ToViewAction (View action) 
Instance details

Defined in Miso.Types

type ToViewAction (View action) = action

Methods

toView :: View action -> View (ToViewAction (View action)) Source #

ToView (Component name model action) Source # 
Instance details

Defined in Miso.Types

Associated Types

type ToViewAction (Component name model action) 
Instance details

Defined in Miso.Types

type ToViewAction (Component name model action) = action

Methods

toView :: Component name model action -> View (ToViewAction (Component name model action)) Source #

class ToKey key where Source #

Convert custom key types to Key.

Instances of this class do not have to guarantee uniqueness of the generated keys, it is up to the user to do so. toKey must be an injective function.

Methods

toKey :: key -> Key Source #

Converts any key into Key

Instances

Instances details
ToKey JSString Source #

Convert MisoString to Key

Instance details

Defined in Miso.Types

Methods

toKey :: JSString -> Key Source #

ToKey Key Source #

Identity instance

Instance details

Defined in Miso.Types

Methods

toKey :: Key -> Key Source #

ToKey Text Source #

Convert T.Text to Key

Instance details

Defined in Miso.Types

Methods

toKey :: Text -> Key Source #

ToKey String Source #

Convert String to Key

Instance details

Defined in Miso.Types

Methods

toKey :: String -> Key Source #

ToKey Double Source #

Convert Double to Key

Instance details

Defined in Miso.Types

Methods

toKey :: Double -> Key Source #

ToKey Float Source #

Convert Float to Key

Instance details

Defined in Miso.Types

Methods

toKey :: Float -> Key Source #

ToKey Int Source #

Convert Int to Key

Instance details

Defined in Miso.Types

Methods

toKey :: Int -> Key Source #

ToKey Word Source #

Convert Word to Key

Instance details

Defined in Miso.Types

Methods

toKey :: Word -> Key Source #

Smart Constructors

defaultComponent :: forall model action (name :: Symbol). model -> (action -> Effect model action) -> (model -> View action) -> Component name model action Source #

Smart constructor for Component with sane defaults.

Components

component_ :: forall (name :: Symbol) model action a. (Eq model, KnownSymbol name) => Component name model action -> [Attribute a] -> View a Source #

Used in the view function to embed an Component into another Component Use this function if you'd like send messages to this Component at name via notify or to read the state of this Component via sample.

Utils

getMountPoint :: Maybe MisoString -> MisoString Source #

Convenience for extracting mount point