{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE StaticPointers #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Miso.Types
(
App
, Component (..)
, ComponentId
, SomeComponent (..)
, SomeStaticComponent (..)
, MountConstraints
, EventHandler (..)
, View (..)
, Key (..)
, Attribute (..)
, Namespace (..)
, CSS (..)
, JS (..)
, LogLevel (..)
, VTree (..)
, VTreeType (..)
, Hydrate (..)
, Tag
, DirectEvents
, CacheBust
, MountPoint
, DOMRef
, Events
, Phase (..)
, URI (..)
, ToKey (..)
, emptyURI
, component
, event
, vcomp
, vcomp_
, (+>)
, mount_
, mountUseContext
, mountWithProps_
, mountWithProps
, mountStatic
, mountStaticWithProps
, fragment
, fragment_
, vfrag
, vfrag_
, vcontext
, withContext
, vprops
, withProps
, vmodel
, withModel
, getMountPoint
, optionalAttrs
, optionalVoidAttrs
, optionalChildren
, prettyURI
, prettyQueryString
, node
, nodeDirectEvents
, vnode
, text
, vtext
, text_
, textRaw
, textKey
, textKey_
, htmlEncode
, MisoString
, toMisoString
, fromMisoString
, ms
) where
import Data.Function
import qualified Data.Map.Strict as M
import Data.Set (Set)
import qualified Data.Set as S
import Data.Maybe (fromMaybe, isJust)
import Data.String (IsString, fromString)
import qualified Data.Text as T
import GHC.Generics
import GHC.StaticPtr
import Prelude
import Miso.DSL
import Miso.Effect (Effect, Sub, Sink, DOMRef, ComponentId)
import Miso.Event.Types
import qualified Miso.Event.Decoder
import Miso.JSON (Value, ToJSON(..), encode)
#ifdef NATIVE
import Miso.JSON (FromJSON(..))
#endif
import qualified Miso.String as MS
import Miso.String (ToMisoString, MisoString, toMisoString, ms, fromMisoString)
import Miso.CSS.Types (StyleSheet)
data Component context props model action
= Component
{ forall context props model action.
Component context props model action -> model
model :: model
, forall context props model action.
Component context props model action -> Maybe (IO model)
hydrateModel :: Maybe (IO model)
, forall context props model action.
Component context props model action
-> action -> Effect context props model action
update :: action -> Effect context props model action
, forall context props model action.
Component context props model action
-> model -> View context props model action
view :: model -> View context props model action
, forall context props model action.
Component context props model action -> Bool
useContext :: Bool
, forall context props model action.
Component context props model action -> [Sub model action]
subs :: [ Sub model action ]
, forall context props model action.
Component context props model action -> [CSS]
styles :: [CSS]
, forall context props model action.
Component context props model action -> [JS]
scripts :: [JS]
, forall context props model action.
Component context props model action -> Maybe Text
mountPoint :: Maybe MountPoint
, forall context props model action.
Component context props model action -> LogLevel
logLevel :: LogLevel
, forall context props model action.
Component context props model action -> Value -> Maybe action
mailbox :: Value -> Maybe action
, forall context props model action.
Component context props model action -> Bool
eventPropagation :: Bool
, forall context props model action.
Component context props model action -> Maybe action
mount :: Maybe action
, forall context props model action.
Component context props model action -> Maybe action
unmount :: Maybe action
, forall context props model action.
Component context props model action
-> Maybe (props -> props -> action)
onPropsChanged :: Maybe (props -> props -> action)
}
type MountPoint = MisoString
data CSS
= Href MisoString CacheBust
| Style MisoString
| Sheet StyleSheet
deriving (Int -> CSS -> ShowS
[CSS] -> ShowS
CSS -> String
(Int -> CSS -> ShowS)
-> (CSS -> String) -> ([CSS] -> ShowS) -> Show CSS
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CSS -> ShowS
showsPrec :: Int -> CSS -> ShowS
$cshow :: CSS -> String
show :: CSS -> String
$cshowList :: [CSS] -> ShowS
showList :: [CSS] -> ShowS
Show, CSS -> CSS -> Bool
(CSS -> CSS -> Bool) -> (CSS -> CSS -> Bool) -> Eq CSS
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CSS -> CSS -> Bool
== :: CSS -> CSS -> Bool
$c/= :: CSS -> CSS -> Bool
/= :: CSS -> CSS -> Bool
Eq)
type CacheBust = Bool
data JS
= Src MisoString CacheBust
| Script MisoString
| Module MisoString
| ImportMap [(MisoString,MisoString)]
deriving (Int -> JS -> ShowS
[JS] -> ShowS
JS -> String
(Int -> JS -> ShowS)
-> (JS -> String) -> ([JS] -> ShowS) -> Show JS
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> JS -> ShowS
showsPrec :: Int -> JS -> ShowS
$cshow :: JS -> String
show :: JS -> String
$cshowList :: [JS] -> ShowS
showList :: [JS] -> ShowS
Show, JS -> JS -> Bool
(JS -> JS -> Bool) -> (JS -> JS -> Bool) -> Eq JS
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: JS -> JS -> Bool
== :: JS -> JS -> Bool
$c/= :: JS -> JS -> Bool
/= :: JS -> JS -> Bool
Eq)
getMountPoint :: Maybe MisoString -> MisoString
getMountPoint :: Maybe Text -> Text
getMountPoint = Text -> Maybe Text -> Text
forall a. a -> Maybe a -> a
fromMaybe Text
"body"
component
:: model
-> (action -> Effect context props model action)
-> (model -> View context props model action)
-> Component context props model action
component :: forall model action context props.
model
-> (action -> Effect context props model action)
-> (model -> View context props model action)
-> Component context props model action
component model
m action -> Effect context props model action
u model -> View context props model action
v = Component
{ model :: model
model = model
m
, hydrateModel :: Maybe (IO model)
hydrateModel = Maybe (IO model)
forall a. Maybe a
Nothing
, update :: action -> Effect context props model action
update = action -> Effect context props model action
u
, view :: model -> View context props model action
view = model -> View context props model action
v
, useContext :: Bool
useContext = Bool
False
, subs :: [Sub model action]
subs = []
, styles :: [CSS]
styles = []
, scripts :: [JS]
scripts = []
, mountPoint :: Maybe Text
mountPoint = Maybe Text
forall a. Maybe a
Nothing
, logLevel :: LogLevel
logLevel = LogLevel
Off
, mailbox :: Value -> Maybe action
mailbox = Maybe action -> Value -> Maybe action
forall a b. a -> b -> a
const Maybe action
forall a. Maybe a
Nothing
, eventPropagation :: Bool
eventPropagation = Bool
False
, mount :: Maybe action
mount = Maybe action
forall a. Maybe a
Nothing
, unmount :: Maybe action
unmount = Maybe action
forall a. Maybe a
Nothing
, onPropsChanged :: Maybe (props -> props -> action)
onPropsChanged = Maybe (props -> props -> action)
forall a. Maybe a
Nothing
}
type App model action = Component () () model action
data LogLevel
= Off
| DebugHydrate
| DebugEvents
| DebugAll
deriving (Int -> LogLevel -> ShowS
[LogLevel] -> ShowS
LogLevel -> String
(Int -> LogLevel -> ShowS)
-> (LogLevel -> String) -> ([LogLevel] -> ShowS) -> Show LogLevel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LogLevel -> ShowS
showsPrec :: Int -> LogLevel -> ShowS
$cshow :: LogLevel -> String
show :: LogLevel -> String
$cshowList :: [LogLevel] -> ShowS
showList :: [LogLevel] -> ShowS
Show, LogLevel -> LogLevel -> Bool
(LogLevel -> LogLevel -> Bool)
-> (LogLevel -> LogLevel -> Bool) -> Eq LogLevel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LogLevel -> LogLevel -> Bool
== :: LogLevel -> LogLevel -> Bool
$c/= :: LogLevel -> LogLevel -> Bool
/= :: LogLevel -> LogLevel -> Bool
Eq)
type Tag = MisoString
type DirectEvents = Set MisoString
data View context props model action
= VNode Namespace Tag [Attribute model action] [View context props model action] DirectEvents
| VText (Maybe Key) MisoString
| VComp (SomeComponent context)
| forall childProps . VCompStatic (StaticPtr (SomeStaticComponent childProps context)) childProps
| VFrag (Maybe Key) [View context props model action]
| VContext (context -> View context props model action)
| VProps (props -> View context props model action)
| VModel (model -> View context props model action)
#ifdef NATIVE
type MountConstraints context props model action =
(Eq context, Eq props, Eq model, FromJSON props, ToJSON props, FromJSON model, ToJSON model, FromJSON action, ToJSON action)
#else
type MountConstraints context props model action =
(Eq context, Eq props, Eq model)
#endif
data SomeComponent context
= forall model action props . MountConstraints context props model action
=> SomeComponent (Maybe Key) props (Component context props model action)
data SomeStaticComponent props context
= forall model action . MountConstraints context props model action
=> SomeStaticComponent (Component context props model action)
vfrag :: [View context props model action] -> View context props model action
vfrag :: forall context props model action.
[View context props model action]
-> View context props model action
vfrag = [View context props model action]
-> View context props model action
forall context props model action.
[View context props model action]
-> View context props model action
fragment
fragment :: [View context props model action] -> View context props model action
fragment :: forall context props model action.
[View context props model action]
-> View context props model action
fragment = Maybe Key
-> [View context props model action]
-> View context props model action
forall context props model action.
Maybe Key
-> [View context props model action]
-> View context props model action
VFrag Maybe Key
forall a. Maybe a
Nothing
vfrag_ :: MisoString -> [View context props model action] -> View context props model action
vfrag_ :: forall context props model action.
Text
-> [View context props model action]
-> View context props model action
vfrag_ Text
key = Maybe Key
-> [View context props model action]
-> View context props model action
forall context props model action.
Maybe Key
-> [View context props model action]
-> View context props model action
VFrag (Key -> Maybe Key
forall a. a -> Maybe a
Just (Text -> Key
Key Text
key))
fragment_ :: MisoString -> [View context props model action] -> View context props model action
fragment_ :: forall context props model action.
Text
-> [View context props model action]
-> View context props model action
fragment_ Text
key = Maybe Key
-> [View context props model action]
-> View context props model action
forall context props model action.
Maybe Key
-> [View context props model action]
-> View context props model action
VFrag (Key -> Maybe Key
forall a. a -> Maybe a
Just (Text -> Key
Key Text
key))
(+>)
:: forall context childModel childAction model action props .
#ifdef NATIVE
(Eq context, Eq childModel, FromJSON childModel, ToJSON childModel, FromJSON childAction, ToJSON childAction)
#else
(Eq context, Eq childModel)
#endif
=> MisoString
-> Component context () childModel childAction
-> View context props model action
infixr 0 +>
#ifdef NATIVE
{-# WARNING (+>) "[NATIVE] '+>' has no StaticKey; a component mounted with it after the initial frame silently drops OnStatic handlers inside it. Use 'vcomp' with 'mountStatic' instead." #-}
#endif
Text
key +> :: forall context childModel childAction model action props.
(Eq context, Eq childModel, FromJSON childModel, ToJSON childModel,
FromJSON childAction, ToJSON childAction) =>
Text
-> Component context () childModel childAction
-> View context props model action
+> Component context () childModel childAction
child = SomeComponent context -> View context props model action
forall context props model action.
SomeComponent context -> View context props model action
VComp (Maybe Key
-> ()
-> Component context () childModel childAction
-> SomeComponent context
forall context model action props.
MountConstraints context props model action =>
Maybe Key
-> props
-> Component context props model action
-> SomeComponent context
SomeComponent (Key -> Maybe Key
forall a. a -> Maybe a
Just (Text -> Key
forall key. ToKey key => key -> Key
toKey Text
key)) () Component context () childModel childAction
child)
mountStaticWithProps
:: MountConstraints context props model action
=> Component context props model action
-> SomeStaticComponent props context
mountStaticWithProps :: forall context props model action.
MountConstraints context props model action =>
Component context props model action
-> SomeStaticComponent props context
mountStaticWithProps = Component context props model action
-> SomeStaticComponent props context
forall props context model action.
MountConstraints context props model action =>
Component context props model action
-> SomeStaticComponent props context
SomeStaticComponent
{-# DEPRECATED mountStaticWithProps "Use mountStatic; it now accepts components with props. This alias will be removed in 1.15." #-}
mountWithProps
:: forall context childProps childModel childAction model action props .
#ifdef NATIVE
(Eq context, Eq childProps, Eq childModel, FromJSON childModel, ToJSON childModel, FromJSON childAction, ToJSON childAction, FromJSON childProps, ToJSON childProps)
#else
(Eq context, Eq childProps, Eq childModel)
#endif
=> childProps
-> Component context childProps childModel childAction
-> View context props model action
#ifdef NATIVE
{-# WARNING mountWithProps "[NATIVE] 'mountWithProps' has no StaticKey; a component mounted with it after the initial frame silently drops OnStatic handlers inside it. Use 'vcomp' with 'mountStatic' instead." #-}
#endif
mountWithProps :: forall context childProps childModel childAction model action
props.
(Eq context, Eq childProps, Eq childModel, FromJSON childModel,
ToJSON childModel, FromJSON childAction, ToJSON childAction,
FromJSON childProps, ToJSON childProps) =>
childProps
-> Component context childProps childModel childAction
-> View context props model action
mountWithProps childProps
props Component context childProps childModel childAction
comp = SomeComponent context -> View context props model action
forall context props model action.
SomeComponent context -> View context props model action
VComp (Maybe Key
-> childProps
-> Component context childProps childModel childAction
-> SomeComponent context
forall context model action props.
MountConstraints context props model action =>
Maybe Key
-> props
-> Component context props model action
-> SomeComponent context
SomeComponent Maybe Key
forall a. Maybe a
Nothing childProps
props Component context childProps childModel childAction
comp)
mountWithProps_
:: forall context childProps childModel childAction model action props .
#ifdef NATIVE
(Eq context, Eq childProps, Eq childModel, FromJSON childAction, FromJSON childModel, ToJSON childModel, ToJSON childAction, FromJSON childProps, ToJSON childProps)
#else
(Eq context, Eq childModel, Eq childProps)
#endif
=> MisoString
-> childProps
-> Component context childProps childModel childAction
-> View context props model action
#ifdef NATIVE
{-# WARNING mountWithProps_ "[NATIVE] 'mountWithProps_' has no StaticKey; a component mounted with it after the initial frame silently drops OnStatic handlers inside it. Use 'vcomp' with 'mountStatic' instead." #-}
#endif
mountWithProps_ :: forall context childProps childModel childAction model action
props.
(Eq context, Eq childProps, Eq childModel, FromJSON childAction,
FromJSON childModel, ToJSON childModel, ToJSON childAction,
FromJSON childProps, ToJSON childProps) =>
Text
-> childProps
-> Component context childProps childModel childAction
-> View context props model action
mountWithProps_ Text
key childProps
props Component context childProps childModel childAction
child = SomeComponent context -> View context props model action
forall context props model action.
SomeComponent context -> View context props model action
VComp (Maybe Key
-> childProps
-> Component context childProps childModel childAction
-> SomeComponent context
forall context model action props.
MountConstraints context props model action =>
Maybe Key
-> props
-> Component context props model action
-> SomeComponent context
SomeComponent (Key -> Maybe Key
forall a. a -> Maybe a
Just (Text -> Key
Key Text
key)) childProps
props Component context childProps childModel childAction
child)
mountStatic
:: MountConstraints context props model action
=> Component context props model action
-> SomeStaticComponent props context
mountStatic :: forall context props model action.
MountConstraints context props model action =>
Component context props model action
-> SomeStaticComponent props context
mountStatic = Component context props model action
-> SomeStaticComponent props context
forall props context model action.
MountConstraints context props model action =>
Component context props model action
-> SomeStaticComponent props context
SomeStaticComponent
mount_
:: forall context childModel childAction model action props .
#ifdef NATIVE
(Eq context, Eq childModel, FromJSON childModel, ToJSON childModel, FromJSON childAction, ToJSON childAction)
#else
(Eq context, Eq childModel)
#endif
=> Component context () childModel childAction
-> View context props model action
#ifdef NATIVE
{-# WARNING mount_ "[NATIVE] 'mount_' has no StaticKey; a component mounted with it after the initial frame silently drops OnStatic handlers inside it. Use 'vcomp_' with 'mountStatic' instead." #-}
#endif
mount_ :: forall context childModel childAction model action props.
(Eq context, Eq childModel, FromJSON childModel, ToJSON childModel,
FromJSON childAction, ToJSON childAction) =>
Component context () childModel childAction
-> View context props model action
mount_ Component context () childModel childAction
comp = SomeComponent context -> View context props model action
forall context props model action.
SomeComponent context -> View context props model action
VComp (Maybe Key
-> ()
-> Component context () childModel childAction
-> SomeComponent context
forall context model action props.
MountConstraints context props model action =>
Maybe Key
-> props
-> Component context props model action
-> SomeComponent context
SomeComponent Maybe Key
forall a. Maybe a
Nothing () Component context () childModel childAction
comp)
vcomp
:: childProps
-> StaticPtr (SomeStaticComponent childProps context)
-> View context props model action
vcomp :: forall childProps context props model action.
childProps
-> StaticPtr (SomeStaticComponent childProps context)
-> View context props model action
vcomp = (StaticPtr (SomeStaticComponent childProps context)
-> childProps -> View context props model action)
-> childProps
-> StaticPtr (SomeStaticComponent childProps context)
-> View context props model action
forall a b c. (a -> b -> c) -> b -> a -> c
flip StaticPtr (SomeStaticComponent childProps context)
-> childProps -> View context props model action
forall context props model action childProps.
StaticPtr (SomeStaticComponent childProps context)
-> childProps -> View context props model action
VCompStatic
vcomp_
:: StaticPtr (SomeStaticComponent () context)
-> View context props model action
vcomp_ :: forall context props model action.
StaticPtr (SomeStaticComponent () context)
-> View context props model action
vcomp_ = ()
-> StaticPtr (SomeStaticComponent () context)
-> View context props model action
forall childProps context props model action.
childProps
-> StaticPtr (SomeStaticComponent childProps context)
-> View context props model action
vcomp ()
mountUseContext
:: forall context childModel childAction model action props .
#ifdef NATIVE
(Eq context, Eq childModel, FromJSON childModel, ToJSON childModel, FromJSON childAction, ToJSON childAction)
#else
(Eq context, Eq childModel)
#endif
=> Component context () childModel childAction
-> View context props model action
#ifdef NATIVE
{-# WARNING mountUseContext "[NATIVE] 'mountUseContext' has no StaticKey; a component mounted with it after the initial frame silently drops OnStatic handlers inside it. Use 'vcomp_' with 'mountStatic' on a component with useContext = True instead." #-}
#endif
mountUseContext :: forall context childModel childAction model action props.
(Eq context, Eq childModel, FromJSON childModel, ToJSON childModel,
FromJSON childAction, ToJSON childAction) =>
Component context () childModel childAction
-> View context props model action
mountUseContext Component context () childModel childAction
comp = SomeComponent context -> View context props model action
forall context props model action.
SomeComponent context -> View context props model action
VComp (Maybe Key
-> ()
-> Component context () childModel childAction
-> SomeComponent context
forall context model action props.
MountConstraints context props model action =>
Maybe Key
-> props
-> Component context props model action
-> SomeComponent context
SomeComponent Maybe Key
forall a. Maybe a
Nothing () Component context () childModel childAction
comp { useContext = True })
vcontext :: (context -> View context props model action) -> View context props model action
vcontext :: forall context props model action.
(context -> View context props model action)
-> View context props model action
vcontext = (context -> View context props model action)
-> View context props model action
forall context props model action.
(context -> View context props model action)
-> View context props model action
VContext
withContext :: (context -> View context props model action) -> View context props model action
withContext :: forall context props model action.
(context -> View context props model action)
-> View context props model action
withContext = (context -> View context props model action)
-> View context props model action
forall context props model action.
(context -> View context props model action)
-> View context props model action
vcontext
vprops :: (props -> View context props model action) -> View context props model action
vprops :: forall props context model action.
(props -> View context props model action)
-> View context props model action
vprops = (props -> View context props model action)
-> View context props model action
forall context props model action.
(props -> View context props model action)
-> View context props model action
VProps
withProps :: (props -> View context props model action) -> View context props model action
withProps :: forall props context model action.
(props -> View context props model action)
-> View context props model action
withProps = (props -> View context props model action)
-> View context props model action
forall props context model action.
(props -> View context props model action)
-> View context props model action
vprops
vmodel :: (model -> View context props model action) -> View context props model action
vmodel :: forall model context props action.
(model -> View context props model action)
-> View context props model action
vmodel = (model -> View context props model action)
-> View context props model action
forall context props model action.
(model -> View context props model action)
-> View context props model action
VModel
withModel :: (model -> View context props model action) -> View context props model action
withModel :: forall model context props action.
(model -> View context props model action)
-> View context props model action
withModel = (model -> View context props model action)
-> View context props model action
forall model context props action.
(model -> View context props model action)
-> View context props model action
vmodel
data Namespace
= HTML
| SVG
| MATHML
deriving (Int -> Namespace -> ShowS
[Namespace] -> ShowS
Namespace -> String
(Int -> Namespace -> ShowS)
-> (Namespace -> String)
-> ([Namespace] -> ShowS)
-> Show Namespace
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Namespace -> ShowS
showsPrec :: Int -> Namespace -> ShowS
$cshow :: Namespace -> String
show :: Namespace -> String
$cshowList :: [Namespace] -> ShowS
showList :: [Namespace] -> ShowS
Show, Namespace -> Namespace -> Bool
(Namespace -> Namespace -> Bool)
-> (Namespace -> Namespace -> Bool) -> Eq Namespace
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Namespace -> Namespace -> Bool
== :: Namespace -> Namespace -> Bool
$c/= :: Namespace -> Namespace -> Bool
/= :: Namespace -> Namespace -> Bool
Eq)
instance ToJSVal Namespace where
toJSVal :: Namespace -> IO JSVal
toJSVal = \case
Namespace
SVG -> Text -> IO JSVal
forall a. ToJSVal a => a -> IO JSVal
toJSVal (Text
"svg" :: MisoString)
Namespace
HTML -> Text -> IO JSVal
forall a. ToJSVal a => a -> IO JSVal
toJSVal (Text
"html" :: MisoString)
Namespace
MATHML -> Text -> IO JSVal
forall a. ToJSVal a => a -> IO JSVal
toJSVal (Text
"mathml" :: MisoString)
newtype Key = Key MisoString
deriving newtype (Int -> Key -> ShowS
[Key] -> ShowS
Key -> String
(Int -> Key -> ShowS)
-> (Key -> String) -> ([Key] -> ShowS) -> Show Key
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Key -> ShowS
showsPrec :: Int -> Key -> ShowS
$cshow :: Key -> String
show :: Key -> String
$cshowList :: [Key] -> ShowS
showList :: [Key] -> ShowS
Show, Key -> Key -> Bool
(Key -> Key -> Bool) -> (Key -> Key -> Bool) -> Eq Key
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Key -> Key -> Bool
== :: Key -> Key -> Bool
$c/= :: Key -> Key -> Bool
/= :: Key -> Key -> Bool
Eq, String -> Key
(String -> Key) -> IsString Key
forall a. (String -> a) -> IsString a
$cfromString :: String -> Key
fromString :: String -> Key
IsString, [Key] -> Value
Key -> Value
(Key -> Value) -> ([Key] -> Value) -> ToJSON Key
forall a. (a -> Value) -> ([a] -> Value) -> ToJSON a
$ctoJSON :: Key -> Value
toJSON :: Key -> Value
$ctoJSONList :: [Key] -> Value
toJSONList :: [Key] -> Value
ToJSON, Key -> Text
(Key -> Text) -> ToMisoString Key
forall str. (str -> Text) -> ToMisoString str
$ctoMisoString :: Key -> Text
toMisoString :: Key -> Text
ToMisoString)
instance ToJSVal Key where
toJSVal :: Key -> IO JSVal
toJSVal (Key Text
x) = Text -> IO JSVal
forall a. ToJSVal a => a -> IO JSVal
toJSVal Text
x
class ToKey key where
toKey :: key -> Key
instance ToKey Key where toKey :: Key -> Key
toKey = Key -> Key
forall a. a -> a
id
#if !defined(VANILLA) && !defined(MISO_TEXT)
instance ToKey MisoString where toKey = Key
#endif
instance ToKey T.Text where toKey :: Text -> Key
toKey = Text -> Key
Key (Text -> Key) -> (Text -> Text) -> Text -> Key
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
forall str. ToMisoString str => str -> Text
toMisoString
instance ToKey String where toKey :: String -> Key
toKey = Text -> Key
Key (Text -> Key) -> (String -> Text) -> String -> Key
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
forall str. ToMisoString str => str -> Text
toMisoString
instance ToKey Int where toKey :: Int -> Key
toKey = Text -> Key
Key (Text -> Key) -> (Int -> Text) -> Int -> Key
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Text
forall str. ToMisoString str => str -> Text
toMisoString
instance ToKey Double where toKey :: Double -> Key
toKey = Text -> Key
Key (Text -> Key) -> (Double -> Text) -> Double -> Key
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Text
forall str. ToMisoString str => str -> Text
toMisoString
instance ToKey Float where toKey :: Float -> Key
toKey = Text -> Key
Key (Text -> Key) -> (Float -> Text) -> Float -> Key
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Float -> Text
forall str. ToMisoString str => str -> Text
toMisoString
instance ToKey Word where toKey :: Word -> Key
toKey = Text -> Key
Key (Text -> Key) -> (Word -> Text) -> Word -> Key
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> Text
forall str. ToMisoString str => str -> Text
toMisoString
data EventHandler model action = forall result. EventHandler
{ forall model action.
EventHandler model action
-> model -> Sink action -> VTree -> LogLevel -> Events -> IO ()
eventHandlerInstall :: model -> Sink action -> VTree -> LogLevel -> Events -> IO ()
, ()
eventHandlerDecoder :: Miso.Event.Decoder.Decoder result
, ()
eventHandlerConvert :: result -> model -> DOMRef -> action
}
event :: StaticPtr (EventHandler model action) -> Attribute model action
event :: forall model action.
StaticPtr (EventHandler model action) -> Attribute model action
event = StaticPtr (EventHandler model action) -> Attribute model action
forall model action.
StaticPtr (EventHandler model action) -> Attribute model action
OnStatic
data Attribute model action
= Property MisoString Value
| ClassList [MisoString]
| On (model -> Sink action -> VTree -> LogLevel -> Events -> IO ())
| OnStatic (StaticPtr (EventHandler model action))
| Styles (M.Map MisoString MisoString)
instance Eq (Attribute model action) where
Property Text
k1 Value
v1 == :: Attribute model action -> Attribute model action -> Bool
== Property Text
k2 Value
v2 = Text
k1 Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
k2 Bool -> Bool -> Bool
&& Value
v1 Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
== Value
v2
ClassList [Text]
x == ClassList [Text]
y = [Text]
x [Text] -> [Text] -> Bool
forall a. Eq a => a -> a -> Bool
== [Text]
y
Styles Map Text Text
x == Styles Map Text Text
y = Map Text Text
x Map Text Text -> Map Text Text -> Bool
forall a. Eq a => a -> a -> Bool
== Map Text Text
y
OnStatic StaticPtr (EventHandler model action)
ptr1 == OnStatic StaticPtr (EventHandler model action)
ptr2 = (Fingerprint -> Fingerprint -> Bool)
-> (StaticPtr (EventHandler model action) -> Fingerprint)
-> StaticPtr (EventHandler model action)
-> StaticPtr (EventHandler model action)
-> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Fingerprint -> Fingerprint -> Bool
forall a. Eq a => a -> a -> Bool
(==) StaticPtr (EventHandler model action) -> Fingerprint
forall a. StaticPtr a -> Fingerprint
staticKey StaticPtr (EventHandler model action)
ptr1 StaticPtr (EventHandler model action)
ptr2
Attribute model action
_ == Attribute model action
_ = Bool
False
instance Show (Attribute model action) where
show :: Attribute model action -> String
show = \case
Property Text
key Value
value ->
Text -> String
MS.unpack Text
key String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
"=" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Text -> String
MS.unpack (Text -> Text
forall str. ToMisoString str => str -> Text
ms (Value -> Text
forall a. ToJSON a => a -> Text
encode Value
value))
ClassList [Text]
classes ->
Text -> String
MS.unpack (Text -> [Text] -> Text
MS.intercalate Text
" " [Text]
classes)
On model -> Sink action -> VTree -> LogLevel -> Events -> IO ()
_ ->
String
"<event-handler>"
OnStatic StaticPtr (EventHandler model action)
ptr ->
String
"<event-handler-with: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Fingerprint -> String
forall a. Show a => a -> String
show (StaticPtr (EventHandler model action) -> Fingerprint
forall a. StaticPtr a -> Fingerprint
staticKey StaticPtr (EventHandler model action)
ptr) String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
">"
Styles Map Text Text
styles ->
Text -> String
MS.unpack (Text -> String) -> Text -> String
forall a b. (a -> b) -> a -> b
$ [Text] -> Text
MS.concat
[ Text
k Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"=" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
v Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
";"
| (Text
k, Text
v) <- Map Text Text -> [(Text, Text)]
forall k a. Map k a -> [(k, a)]
M.toList Map Text Text
styles
]
instance IsString (View context props model action) where
fromString :: String -> View context props model action
fromString = Maybe Key -> Text -> View context props model action
forall context props model action.
Maybe Key -> Text -> View context props model action
VText Maybe Key
forall a. Maybe a
Nothing (Text -> View context props model action)
-> (String -> Text) -> String -> View context props model action
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
forall a. IsString a => String -> a
fromString
newtype VTree = VTree
{ VTree -> Object
getTree :: Object
} deriving newtype (VTree -> IO Object
(VTree -> IO Object) -> ToObject VTree
forall a. (a -> IO Object) -> ToObject a
$ctoObject :: VTree -> IO Object
toObject :: VTree -> IO Object
ToObject, VTree -> IO JSVal
(VTree -> IO JSVal) -> ToJSVal VTree
forall a. (a -> IO JSVal) -> ToJSVal a
$ctoJSVal :: VTree -> IO JSVal
toJSVal :: VTree -> IO JSVal
ToJSVal)
node
:: Namespace
-> MisoString
-> [Attribute model action]
-> [View context props model action]
-> View context props model action
node :: forall model action context props.
Namespace
-> Text
-> [Attribute model action]
-> [View context props model action]
-> View context props model action
node Namespace
ns Text
tag [Attribute model action]
attrs [View context props model action]
kids = Namespace
-> Text
-> [Attribute model action]
-> [View context props model action]
-> Set Text
-> View context props model action
forall context props model action.
Namespace
-> Text
-> [Attribute model action]
-> [View context props model action]
-> Set Text
-> View context props model action
VNode Namespace
ns Text
tag [Attribute model action]
attrs [View context props model action]
kids Set Text
forall a. Monoid a => a
mempty
nodeDirectEvents
:: Namespace
-> MisoString
-> [Attribute model action]
-> [MisoString]
-> [View context props model action]
-> View context props model action
nodeDirectEvents :: forall model action context props.
Namespace
-> Text
-> [Attribute model action]
-> [Text]
-> [View context props model action]
-> View context props model action
nodeDirectEvents Namespace
ns Text
tag [Attribute model action]
attrs [Text]
direct [View context props model action]
kids = Namespace
-> Text
-> [Attribute model action]
-> [View context props model action]
-> Set Text
-> View context props model action
forall context props model action.
Namespace
-> Text
-> [Attribute model action]
-> [View context props model action]
-> Set Text
-> View context props model action
VNode Namespace
ns Text
tag [Attribute model action]
attrs [View context props model action]
kids ([Text] -> Set Text
forall a. Ord a => [a] -> Set a
S.fromList [Text]
direct)
vnode
:: Namespace
-> MisoString
-> [Attribute model action]
-> [View context props model action]
-> View context props model action
vnode :: forall model action context props.
Namespace
-> Text
-> [Attribute model action]
-> [View context props model action]
-> View context props model action
vnode = Namespace
-> Text
-> [Attribute model action]
-> [View context props model action]
-> View context props model action
forall model action context props.
Namespace
-> Text
-> [Attribute model action]
-> [View context props model action]
-> View context props model action
node
text :: MisoString -> View context props model action
#ifdef SSR
text = VText Nothing . htmlEncode
#else
text :: forall context props model action.
Text -> View context props model action
text = Maybe Key -> Text -> View context props model action
forall context props model action.
Maybe Key -> Text -> View context props model action
VText Maybe Key
forall a. Maybe a
Nothing
#endif
vtext :: MisoString -> View context props model action
vtext :: forall context props model action.
Text -> View context props model action
vtext = Text -> View context props model action
forall context props model action.
Text -> View context props model action
text
textRaw :: MisoString -> View context props model action
= Maybe Key -> Text -> View context props model action
forall context props model action.
Maybe Key -> Text -> View context props model action
VText Maybe Key
forall a. Maybe a
Nothing
htmlEncode :: MisoString -> MisoString
htmlEncode :: Text -> Text
htmlEncode = (Char -> Text) -> Text -> Text
MS.concatMap ((Char -> Text) -> Text -> Text) -> (Char -> Text) -> Text -> Text
forall a b. (a -> b) -> a -> b
$ \case
Char
'<' -> Text
"<"
Char
'>' -> Text
">"
Char
'&' -> Text
"&"
Char
'"' -> Text
"""
Char
'\'' -> Text
"'"
Char
x -> Char -> Text
MS.singleton Char
x
text_ :: [MisoString] -> View context props model action
text_ :: forall context props model action.
[Text] -> View context props model action
text_ = Maybe Key -> Text -> View context props model action
forall context props model action.
Maybe Key -> Text -> View context props model action
VText Maybe Key
forall a. Maybe a
Nothing (Text -> View context props model action)
-> ([Text] -> Text) -> [Text] -> View context props model action
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> [Text] -> Text
MS.intercalate Text
" "
textKey :: ToKey key => key -> MisoString -> View context props model action
textKey :: forall key context props model action.
ToKey key =>
key -> Text -> View context props model action
textKey key
k = Maybe Key -> Text -> View context props model action
forall context props model action.
Maybe Key -> Text -> View context props model action
VText (Key -> Maybe Key
forall a. a -> Maybe a
Just (key -> Key
forall key. ToKey key => key -> Key
toKey key
k))
textKey_ :: ToKey key => key -> [MisoString] -> View context props model action
textKey_ :: forall key context props model action.
ToKey key =>
key -> [Text] -> View context props model action
textKey_ key
k [Text]
xs = Maybe Key -> Text -> View context props model action
forall context props model action.
Maybe Key -> Text -> View context props model action
VText (Key -> Maybe Key
forall a. a -> Maybe a
Just (key -> Key
forall key. ToKey key => key -> Key
toKey key
k)) (Text -> [Text] -> Text
MS.intercalate Text
" " [Text]
xs)
optionalAttrs
:: ([Attribute model action] -> [View context props model action] -> View context props model action)
-> [Attribute model action]
-> Bool
-> [Attribute model action]
-> [View context props model action]
-> View context props model action
optionalAttrs :: forall model action context props.
([Attribute model action]
-> [View context props model action]
-> View context props model action)
-> [Attribute model action]
-> Bool
-> [Attribute model action]
-> [View context props model action]
-> View context props model action
optionalAttrs [Attribute model action]
-> [View context props model action]
-> View context props model action
element [Attribute model action]
attrs Bool
condition [Attribute model action]
opts [View context props model action]
kids =
case [Attribute model action]
-> [View context props model action]
-> View context props model action
element [Attribute model action]
attrs [View context props model action]
kids of
VNode Namespace
ns Text
name [Attribute model action]
_ [View context props model action]
_ Set Text
de -> do
let newAttrs :: [Attribute model action]
newAttrs = [[Attribute model action]] -> [Attribute model action]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [ [Attribute model action]
opts | Bool
condition ] [Attribute model action]
-> [Attribute model action] -> [Attribute model action]
forall a. [a] -> [a] -> [a]
++ [Attribute model action]
attrs
Namespace
-> Text
-> [Attribute model action]
-> [View context props model action]
-> Set Text
-> View context props model action
forall context props model action.
Namespace
-> Text
-> [Attribute model action]
-> [View context props model action]
-> Set Text
-> View context props model action
VNode Namespace
ns Text
name [Attribute model action]
newAttrs [View context props model action]
kids Set Text
de
View context props model action
x -> View context props model action
x
optionalVoidAttrs
:: ([Attribute model action] -> View context props model action)
-> [Attribute model action]
-> Bool
-> [Attribute model action]
-> View context props model action
optionalVoidAttrs :: forall model action context props.
([Attribute model action] -> View context props model action)
-> [Attribute model action]
-> Bool
-> [Attribute model action]
-> View context props model action
optionalVoidAttrs [Attribute model action] -> View context props model action
element [Attribute model action]
attrs Bool
condition [Attribute model action]
opts =
case [Attribute model action] -> View context props model action
element [Attribute model action]
attrs of
VNode Namespace
ns Text
name [Attribute model action]
_ [View context props model action]
kids Set Text
de -> do
let newAttrs :: [Attribute model action]
newAttrs = [[Attribute model action]] -> [Attribute model action]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [ [Attribute model action]
opts | Bool
condition ] [Attribute model action]
-> [Attribute model action] -> [Attribute model action]
forall a. [a] -> [a] -> [a]
++ [Attribute model action]
attrs
Namespace
-> Text
-> [Attribute model action]
-> [View context props model action]
-> Set Text
-> View context props model action
forall context props model action.
Namespace
-> Text
-> [Attribute model action]
-> [View context props model action]
-> Set Text
-> View context props model action
VNode Namespace
ns Text
name [Attribute model action]
newAttrs [View context props model action]
kids Set Text
de
View context props model action
x -> View context props model action
x
optionalChildren
:: ([Attribute model action] -> [View context props model action] -> View context props model action)
-> [Attribute model action]
-> [View context props model action]
-> Bool
-> [View context props model action]
-> View context props model action
optionalChildren :: forall model action context props.
([Attribute model action]
-> [View context props model action]
-> View context props model action)
-> [Attribute model action]
-> [View context props model action]
-> Bool
-> [View context props model action]
-> View context props model action
optionalChildren [Attribute model action]
-> [View context props model action]
-> View context props model action
element [Attribute model action]
attrs [View context props model action]
kids Bool
condition [View context props model action]
opts =
case [Attribute model action]
-> [View context props model action]
-> View context props model action
element [Attribute model action]
attrs [View context props model action]
kids of
VNode Namespace
ns Text
name [Attribute model action]
_ [View context props model action]
_ Set Text
de -> do
let newKids :: [View context props model action]
newKids = [View context props model action]
kids [View context props model action]
-> [View context props model action]
-> [View context props model action]
forall a. [a] -> [a] -> [a]
++ [[View context props model action]]
-> [View context props model action]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [ [View context props model action]
opts | Bool
condition ]
Namespace
-> Text
-> [Attribute model action]
-> [View context props model action]
-> Set Text
-> View context props model action
forall context props model action.
Namespace
-> Text
-> [Attribute model action]
-> [View context props model action]
-> Set Text
-> View context props model action
VNode Namespace
ns Text
name [Attribute model action]
attrs [View context props model action]
newKids Set Text
de
View context props model action
x -> View context props model action
x
data URI
= URI
{ URI -> Text
uriPath :: MisoString
, URI -> Text
uriFragment :: MisoString
, URI -> Map Text (Maybe Text)
uriQueryString :: M.Map MisoString (Maybe MisoString)
} deriving stock (Int -> URI -> ShowS
[URI] -> ShowS
URI -> String
(Int -> URI -> ShowS)
-> (URI -> String) -> ([URI] -> ShowS) -> Show URI
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> URI -> ShowS
showsPrec :: Int -> URI -> ShowS
$cshow :: URI -> String
show :: URI -> String
$cshowList :: [URI] -> ShowS
showList :: [URI] -> ShowS
Show, URI -> URI -> Bool
(URI -> URI -> Bool) -> (URI -> URI -> Bool) -> Eq URI
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: URI -> URI -> Bool
== :: URI -> URI -> Bool
$c/= :: URI -> URI -> Bool
/= :: URI -> URI -> Bool
Eq, (forall x. URI -> Rep URI x)
-> (forall x. Rep URI x -> URI) -> Generic URI
forall x. Rep URI x -> URI
forall x. URI -> Rep URI x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. URI -> Rep URI x
from :: forall x. URI -> Rep URI x
$cto :: forall x. Rep URI x -> URI
to :: forall x. Rep URI x -> URI
Generic)
deriving anyclass (URI -> IO JSVal
(URI -> IO JSVal) -> ToJSVal URI
forall a. (a -> IO JSVal) -> ToJSVal a
$ctoJSVal :: URI -> IO JSVal
toJSVal :: URI -> IO JSVal
ToJSVal, URI -> IO Object
(URI -> IO Object) -> ToObject URI
forall a. (a -> IO Object) -> ToObject a
$ctoObject :: URI -> IO Object
toObject :: URI -> IO Object
ToObject)
emptyURI :: URI
emptyURI :: URI
emptyURI = Text -> Text -> Map Text (Maybe Text) -> URI
URI Text
forall a. Monoid a => a
mempty Text
forall a. Monoid a => a
mempty Map Text (Maybe Text)
forall a. Monoid a => a
mempty
instance ToMisoString URI where
toMisoString :: URI -> Text
toMisoString = URI -> Text
prettyURI
instance ToJSON URI where
toJSON :: URI -> Value
toJSON = Text -> Value
forall a. ToJSON a => a -> Value
toJSON (Text -> Value) -> (URI -> Text) -> URI -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. URI -> Text
forall str. ToMisoString str => str -> Text
toMisoString
prettyURI :: URI -> MisoString
prettyURI :: URI -> Text
prettyURI uri :: URI
uri@URI {Map Text (Maybe Text)
Text
uriPath :: URI -> Text
uriFragment :: URI -> Text
uriQueryString :: URI -> Map Text (Maybe Text)
uriPath :: Text
uriFragment :: Text
uriQueryString :: Map Text (Maybe Text)
..} = Text
"/" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
uriPath Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> URI -> Text
prettyQueryString URI
uri Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
uriFragment
prettyQueryString :: URI -> MisoString
prettyQueryString :: URI -> Text
prettyQueryString URI {Map Text (Maybe Text)
Text
uriPath :: URI -> Text
uriFragment :: URI -> Text
uriQueryString :: URI -> Map Text (Maybe Text)
uriPath :: Text
uriFragment :: Text
uriQueryString :: Map Text (Maybe Text)
..} = Text
queries Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
flags
where
queries :: Text
queries =
[Text] -> Text
MS.concat
[ Text
"?" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>
Text -> [Text] -> Text
MS.intercalate Text
"&"
[ Text
k Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"=" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
v
| (Text
k, Just Text
v) <- Map Text (Maybe Text) -> [(Text, Maybe Text)]
forall k a. Map k a -> [(k, a)]
M.toList Map Text (Maybe Text)
uriQueryString
]
| (Maybe Text -> Bool) -> [Maybe Text] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any Maybe Text -> Bool
forall a. Maybe a -> Bool
isJust (Map Text (Maybe Text) -> [Maybe Text]
forall k a. Map k a -> [a]
M.elems Map Text (Maybe Text)
uriQueryString)
]
flags :: Text
flags = [Text] -> Text
forall a. Monoid a => [a] -> a
mconcat
[ Text
"?" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
k
| (Text
k, Maybe Text
Nothing) <- Map Text (Maybe Text) -> [(Text, Maybe Text)]
forall k a. Map k a -> [(k, a)]
M.toList Map Text (Maybe Text)
uriQueryString
]
data VTreeType
= VCompType
| VNodeType
| VTextType
| VFragType
deriving (Int -> VTreeType -> ShowS
[VTreeType] -> ShowS
VTreeType -> String
(Int -> VTreeType -> ShowS)
-> (VTreeType -> String)
-> ([VTreeType] -> ShowS)
-> Show VTreeType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VTreeType -> ShowS
showsPrec :: Int -> VTreeType -> ShowS
$cshow :: VTreeType -> String
show :: VTreeType -> String
$cshowList :: [VTreeType] -> ShowS
showList :: [VTreeType] -> ShowS
Show, VTreeType -> VTreeType -> Bool
(VTreeType -> VTreeType -> Bool)
-> (VTreeType -> VTreeType -> Bool) -> Eq VTreeType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VTreeType -> VTreeType -> Bool
== :: VTreeType -> VTreeType -> Bool
$c/= :: VTreeType -> VTreeType -> Bool
/= :: VTreeType -> VTreeType -> Bool
Eq)
instance ToJSVal VTreeType where
toJSVal :: VTreeType -> IO JSVal
toJSVal = \case
VTreeType
VCompType -> Int -> IO JSVal
forall a. ToJSVal a => a -> IO JSVal
toJSVal (Int
0 :: Int)
VTreeType
VNodeType -> Int -> IO JSVal
forall a. ToJSVal a => a -> IO JSVal
toJSVal (Int
1 :: Int)
VTreeType
VTextType -> Int -> IO JSVal
forall a. ToJSVal a => a -> IO JSVal
toJSVal (Int
2 :: Int)
VTreeType
VFragType -> Int -> IO JSVal
forall a. ToJSVal a => a -> IO JSVal
toJSVal (Int
3 :: Int)
data Hydrate
= Draw
| Hydrate
deriving (Int -> Hydrate -> ShowS
[Hydrate] -> ShowS
Hydrate -> String
(Int -> Hydrate -> ShowS)
-> (Hydrate -> String) -> ([Hydrate] -> ShowS) -> Show Hydrate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Hydrate -> ShowS
showsPrec :: Int -> Hydrate -> ShowS
$cshow :: Hydrate -> String
show :: Hydrate -> String
$cshowList :: [Hydrate] -> ShowS
showList :: [Hydrate] -> ShowS
Show, Hydrate -> Hydrate -> Bool
(Hydrate -> Hydrate -> Bool)
-> (Hydrate -> Hydrate -> Bool) -> Eq Hydrate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Hydrate -> Hydrate -> Bool
== :: Hydrate -> Hydrate -> Bool
$c/= :: Hydrate -> Hydrate -> Bool
/= :: Hydrate -> Hydrate -> Bool
Eq)