| Copyright | (C) 2016-2026 David M. Johnson |
|---|---|
| License | BSD3-style (see the file LICENSE) |
| Maintainer | David M. Johnson <code@dmj.io> |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Miso.JSON.Types
Contents
Description
Overview
Miso.JSON.Types defines the two core types used throughout miso's JSON support:
Value— an RFC 8259-compliant JSON value. Used as the intermediate representation in event decoders (Miso.Event.Decoder) and inToJSVal/FromJSValmarshalling.Result— a lightweight error monad () used by JSON parsers to report decode failures. It has fullSuccessa |ErrorMisoStringFunctor,Applicative,Monad,MonadFail,Alternative,Foldable, andTraversableinstances.
This module was ported from https://github.com/dmjio/json-test by @ners.
Value constructors
dataValue=NumberDouble -- JSON number |BoolBool -- JSON boolean |StringMisoString-- JSON string |Array[Value] -- JSON array |Object(Object) -- JSON object (Map MisoString Value) |Null-- JSON null
See also
- Miso.JSON — top-level re-export hub;
FromJSON,ToJSON,(,.:)withObject - Miso.JSON.Parser — pure server-side JSON decoder (
decodePure) - Miso.JSON.Lexer — tokenizer used by the parser
- Miso.Event.Decoder — uses
ValueandResultviaParser
Synopsis
- data Value
- data Result a
- = Success a
- | Error MisoString
- type Pair = (MisoString, Value)
- type Object = Map MisoString Value
Types
Constructors
| Number Double | |
| Bool Bool | |
| String MisoString | |
| Array [Value] | |
| Object (Map MisoString Value) | |
| Null |
Instances
| IsString Value Source # | |
Defined in Miso.JSON.Types Methods fromString :: String -> Value # | |
| Show Value Source # | |
| Eq Value Source # | |
| FromJSVal Value Source # | |
| ToJSVal Value Source # | |
| FromJSON Value Source # | |
| ToJSON Value Source # | |
| FromMisoString Value Source # | |
Defined in Miso.JSON Methods fromMisoStringEither :: MisoString -> Either String Value Source # | |
| ToMisoString Value Source # | |
Defined in Miso.JSON Methods toMisoString :: Value -> MisoString Source # | |
Constructors
| Success a | |
| Error MisoString |
Instances
| Alternative Result Source # | |
| Applicative Result Source # | |
| Functor Result Source # | |
| Monad Result Source # | |
| MonadPlus Result Source # | |
| MonadFail Result Source # | |
Defined in Miso.JSON.Types | |
| Foldable Result Source # | |
Defined in Miso.JSON.Types Methods fold :: Monoid m => Result m -> m # foldMap :: Monoid m => (a -> m) -> Result a -> m # foldMap' :: Monoid m => (a -> m) -> Result a -> m # foldr :: (a -> b -> b) -> b -> Result a -> b # foldr' :: (a -> b -> b) -> b -> Result a -> b # foldl :: (b -> a -> b) -> b -> Result a -> b # foldl' :: (b -> a -> b) -> b -> Result a -> b # foldr1 :: (a -> a -> a) -> Result a -> a # foldl1 :: (a -> a -> a) -> Result a -> a # elem :: Eq a => a -> Result a -> Bool # maximum :: Ord a => Result a -> a # minimum :: Ord a => Result a -> a # | |
| Traversable Result Source # | |
| Monoid (Result a) Source # | |
| Semigroup (Result a) Source # | |
| Show a => Show (Result a) Source # | |
| Eq a => Eq (Result a) Source # | |
type Pair = (MisoString, Value) Source #