miso 0.5.0.0 → 0.6.0.0
raw patch · 9 files changed
+33/−14 lines, 9 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Miso.String: instance Miso.String.ToMisoString Data.Aeson.Types.Internal.Value
+ Miso.String: ms :: ToMisoString str => str -> MisoString
- Miso.Html: text :: ToMisoString str => str -> View action
+ Miso.Html: text :: MisoString -> View action
Files
- README.md +1/−1
- examples/compose-update/Main.hs +3/−1
- examples/router/Main.hs +1/−0
- exe/Main.hs +4/−1
- ghc-src/Miso/Html/Internal.hs +2/−2
- ghc-src/Miso/String.hs +10/−3
- ghcjs-src/Miso/Html/Internal.hs +2/−2
- ghcjs-src/Miso/String.hs +9/−3
- miso.cabal +1/−1
README.md view
@@ -361,7 +361,7 @@ viewModel :: Model -> View Action viewModel x = div_ [] [ button_ [ onClick AddOne ] [ text "+" ]- , text (show x)+ , text $ toMisoString (show x) , button_ [ onClick SubtractOne ] [ text "-" ] ] ```
examples/compose-update/Main.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE TupleSections #-}+{-# LANGUAGE OverloadedStrings #-} module Main where -- This example demonstrates how you can split your update function@@ -13,6 +14,7 @@ import Miso import Miso.Lens+import Miso.String -- In this slightly contrived example, our model consists of two -- counters. When one of those counters is incremented, the other is@@ -100,6 +102,6 @@ div_ [] [ button_ [onClick Increment] [text "+"]- , text (show x <> " | " <> show y)+ , text (ms (show x) <> " | " <> ms (show y)) , button_ [onClick Decrement] [text "-"] ]
examples/router/Main.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE RecordWildCards #-}
exe/Main.hs view
@@ -1,7 +1,9 @@+{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} module Main where import Miso+import Miso.String type Model = Int @@ -31,6 +33,7 @@ viewModel :: Int -> View Action viewModel x = div_ [] [ button_ [ onClick AddOne ] [ text "+" ]- , text (show x)+ , text $ ms (show x) , button_ [ onClick SubtractOne ] [ text "-" ] ]+
ghc-src/Miso/Html/Internal.hs view
@@ -132,8 +132,8 @@ in View VNode {..} -- | `VText` creation-text :: ToMisoString str => str -> View action-text x = View $ VText (toMisoString x)+text :: MisoString -> View action+text = View . VText -- | Key for specific children patch newtype Key = Key MisoString
ghc-src/Miso/String.hs view
@@ -13,12 +13,14 @@ module Miso.String ( ToMisoString (..) , MisoString+ , module Data.Monoid , module Data.Text+ , ms ) where -import Data.Aeson import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as BL+import Data.Monoid import Data.Text import qualified Data.Text as T import qualified Data.Text.Encoding as T@@ -29,10 +31,15 @@ type MisoString = Text -- | Convenience class for creating `MisoString` from other string-like types-class ToMisoString str where toMisoString :: str -> MisoString+class ToMisoString str where+ toMisoString :: str -> MisoString++-- | Convenience function, shorthand for `toMisoString`+ms :: ToMisoString str => str -> MisoString+ms = toMisoString+ instance ToMisoString MisoString where toMisoString = id instance ToMisoString String where toMisoString = T.pack instance ToMisoString LT.Text where toMisoString = LT.toStrict instance ToMisoString B.ByteString where toMisoString = toMisoString . T.decodeUtf8 instance ToMisoString BL.ByteString where toMisoString = toMisoString . LT.decodeUtf8-instance ToMisoString Value where toMisoString = toMisoString . encode
ghcjs-src/Miso/Html/Internal.hs view
@@ -142,11 +142,11 @@ deriving (Show, Eq) -- | `VText` creation-text :: ToMisoString str => str -> View m+text :: MisoString -> View m text t = View . const $ do vtree <- create set "type" ("vtext" :: JSString) vtree- set "text" (toMisoString t) vtree+ set "text" t vtree pure $ VTree vtree -- | For use with child reconciliaton algorithm
ghcjs-src/Miso/String.hs view
@@ -14,9 +14,11 @@ -- Portability : non-portable ---------------------------------------------------------------------------- module Miso.String (- MisoString+ ToMisoString (..)+ , MisoString , module Data.JSString- , ToMisoString (..)+ , module Data.Monoid+ , ms ) where import Data.Aeson@@ -24,6 +26,7 @@ import qualified Data.ByteString.Lazy as BL import Data.JSString import Data.JSString.Text+import Data.Monoid import qualified Data.Text as T import qualified Data.Text.Encoding as T import qualified Data.Text.Lazy as LT@@ -46,10 +49,13 @@ class ToMisoString str where toMisoString :: str -> MisoString +-- | Convenience function, shorthand for `toMisoString`+ms :: ToMisoString str => str -> MisoString+ms = toMisoString+ instance ToMisoString MisoString where toMisoString = id instance ToMisoString String where toMisoString = pack instance ToMisoString T.Text where toMisoString = textToJSString instance ToMisoString LT.Text where toMisoString = lazyTextToJSString instance ToMisoString B.ByteString where toMisoString = toMisoString . T.decodeUtf8 instance ToMisoString BL.ByteString where toMisoString = toMisoString . LT.decodeUtf8-instance ToMisoString Value where toMisoString = toMisoString . encode
miso.cabal view
@@ -1,5 +1,5 @@ name: miso-version: 0.5.0.0+version: 0.6.0.0 category: Web, Miso, Data Structures license: BSD3 license-file: LICENSE