distributors-json
Copyright(C) 2026 - Eitan Chatav
LicenseBSD-style (see the file LICENSE)
MaintainerEitan Chatav <eitan.chatav@gmail.com>
Stabilityprovisional
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Control.Lens.Grammar.Json

Description

A Json grammar of a type parses, prints & encodes its JSON, compatibly with aeson, & types it in TypeScript, all at once.

Deriving

A Generic type derives its grammar, by aeson's default options.

>>> :{
data Person = Person {name :: Text, age :: Int, email :: Maybe Text}
  deriving stock (Show, Generic)
  deriving anyclass Json
:}
>>> LByteString.putStrLn (encodingToLazyByteString (jsonEncode (Person "Ada" 36 Nothing)))
{"name":"Ada","age":36,"email":null}
>>> jsonDecode @Person "{\"name\":\"Ada\",\"age\":36}"
Right (Person {name = "Ada", age = 36, email = Nothing})

Failures are located, & name what they expected.

>>> either explain show (jsonDecode @Person "{\"name\":\"Ada\",\"age\":\"36\"}")
"Error in $.age: expected Int, but found \"36\""

aeson

ViaJson derives aeson's instances, & jsonGeneric takes aeson's Options.

>>> :{
data Pet = Cat | Dog
  deriving stock (Show, Generic)
  deriving (Aeson.ToJSON, Aeson.FromJSON) via ViaJson Pet
instance Json Pet where
  json = jsonGeneric Aeson.defaultOptions {Aeson.constructorTagModifier = map toLower}
:}
>>> Aeson.encode [Cat, Dog]
"[\"cat\",\"dog\"]"

Grammars

A grammar is written once, with the combinators of JsonVal, JsonObj, JsonTup & JsonStr, & jsonTyped names its type.

>>> :{
data Point = Point Double Double
  deriving stock Show
instance Json Point where
  json = jsonTyped $ iso (\(Point x y) -> (x, y)) (uncurry Point)
    >~ jsonObject ("x" !: json >*< "y" ?: json != 0)
:}
>>> jsonDecode @Point "{\"x\":1}"
Right (Point 1.0 0.0)
>>> jsonPrint (Point 1 0)
Object (fromList [("x",Number 1.0)])

A tuple is an array of elements, & a sum is the alternative grammars of its constructors, here tagged by string literals.

>>> :{
data Shape = Circle Double | Rectangle Double Double
  deriving stock Show
_Circle :: Prism' Shape Double
_Circle = prism' Circle (\case Circle r -> Just r; _ -> Nothing)
_Rectangle :: Prism' Shape (Double, Double)
_Rectangle = prism' (uncurry Rectangle) (\case Rectangle w h -> Just (w, h); _ -> Nothing)
instance Json Shape where
  json = jsonTyped $ orP
    [ _Circle >? jsonObject ("kind" !: "circle" >* "radius" !: json)
    , _Rectangle >? jsonObject ("kind" !: "rectangle" >* "size" !: jsonTuple (jsonElem json >*< jsonElem json))
    ]
:}
>>> LByteString.putStrLn (encodingToLazyByteString (jsonEncode [Circle 1, Rectangle 2 3]))
[{"kind":"circle","radius":1.0},{"kind":"rectangle","size":[2.0,3.0]}]

Types

jsonTsPut puts the TypeScript declarations of types' JSON, which jsonTsDeclarations declares, by Control.Lens.Grammar.TypeScript, & jsonType types.

>>> jsonTsPut (type '[Person, Point, Shape]) stdout
export type Double = number | null | "+inf" | "-inf";
export type Int = number;
export type Person = { name: string; age: Int; email?: null | string };
export type Point = { x: Double; y?: Double };
export type Shape = { kind: "circle"; radius: Double } | { kind: "rectangle"; size: [Double, Double] };
Synopsis

Json

class Json a where Source #

A type with a JSON grammar, like aeson's ToJSON & FromJSON together, which every JsonVal interprets. Its methods default to aeson's defaults, & json to the Generic grammar, by aeson's default options.

Minimal complete definition

Nothing

Methods

json :: JsonVal p => p a a Source #

toJSON & parseJSON, as one grammar.

default json :: forall (d :: Meta) (f :: Type -> Type) p. (Generic a, Rep a ~ D1 d f, GSum f, Typeable a, EnumTag (AllNullary f) a, JsonVal p) => p a a Source #

jsonList :: JsonVal p => p [a] [a] Source #

toJSONList & parseJSONList, as one grammar, an array of values by default. Char and wrappers override it, so that a String is a JSON string.

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k a a) Source #

toJSONKey & parseJSONKey as one grammar for the text keys of objects, or else Nothing for the keys of arrays of pairs.

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [a] [a]) Source #

toJSONKeyList & parseJSONKeyList as one grammar for keys of lists, like jsonList. Char and wrappers override it.

jsonOmitField :: Maybe (APrism' a ()) Source #

omitField & omittedField together, as the value of a record's field which may be omitted, like nearly: it matches the value omitted by omitNothingFields, & reviews the value of a field omitted by allowOmittedFields.

Instances

Instances details
Json Key Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p Key Key Source #

jsonList :: JsonVal p => p [Key] [Key] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k Key Key) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Key] [Key]) Source #

jsonOmitField :: Maybe (APrism' Key ()) Source #

Json DotNetTime Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Json Value Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p Value Value Source #

jsonList :: JsonVal p => p [Value] [Value] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k Value Value) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Value] [Value]) Source #

jsonOmitField :: Maybe (APrism' Value ()) Source #

Json IntSet Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p IntSet IntSet Source #

jsonList :: JsonVal p => p [IntSet] [IntSet] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k IntSet IntSet) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [IntSet] [IntSet]) Source #

jsonOmitField :: Maybe (APrism' IntSet ()) Source #

Json Void Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p Void Void Source #

jsonList :: JsonVal p => p [Void] [Void] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k Void Void) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Void] [Void]) Source #

jsonOmitField :: Maybe (APrism' Void ()) Source #

Json All Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p All All Source #

jsonList :: JsonVal p => p [All] [All] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k All All) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [All] [All]) Source #

jsonOmitField :: Maybe (APrism' All ()) Source #

Json Any Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p Any Any Source #

jsonList :: JsonVal p => p [Any] [Any] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k Any Any) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Any] [Any]) Source #

jsonOmitField :: Maybe (APrism' Any ()) Source #

Json Version Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Json CTime Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p CTime CTime Source #

jsonList :: JsonVal p => p [CTime] [CTime] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k CTime CTime) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [CTime] [CTime]) Source #

jsonOmitField :: Maybe (APrism' CTime ()) Source #

Json Int16 Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p Int16 Int16 Source #

jsonList :: JsonVal p => p [Int16] [Int16] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k Int16 Int16) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Int16] [Int16]) Source #

jsonOmitField :: Maybe (APrism' Int16 ()) Source #

Json Int32 Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p Int32 Int32 Source #

jsonList :: JsonVal p => p [Int32] [Int32] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k Int32 Int32) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Int32] [Int32]) Source #

jsonOmitField :: Maybe (APrism' Int32 ()) Source #

Json Int64 Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p Int64 Int64 Source #

jsonList :: JsonVal p => p [Int64] [Int64] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k Int64 Int64) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Int64] [Int64]) Source #

jsonOmitField :: Maybe (APrism' Int64 ()) Source #

Json Int8 Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p Int8 Int8 Source #

jsonList :: JsonVal p => p [Int8] [Int8] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k Int8 Int8) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Int8] [Int8]) Source #

jsonOmitField :: Maybe (APrism' Int8 ()) Source #

Json Word16 Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p Word16 Word16 Source #

jsonList :: JsonVal p => p [Word16] [Word16] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k Word16 Word16) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Word16] [Word16]) Source #

jsonOmitField :: Maybe (APrism' Word16 ()) Source #

Json Word32 Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p Word32 Word32 Source #

jsonList :: JsonVal p => p [Word32] [Word32] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k Word32 Word32) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Word32] [Word32]) Source #

jsonOmitField :: Maybe (APrism' Word32 ()) Source #

Json Word64 Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p Word64 Word64 Source #

jsonList :: JsonVal p => p [Word64] [Word64] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k Word64 Word64) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Word64] [Word64]) Source #

jsonOmitField :: Maybe (APrism' Word64 ()) Source #

Json Word8 Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p Word8 Word8 Source #

jsonList :: JsonVal p => p [Word8] [Word8] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k Word8 Word8) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Word8] [Word8]) Source #

jsonOmitField :: Maybe (APrism' Word8 ()) Source #

Json Ordering Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Json URI Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p URI URI Source #

jsonList :: JsonVal p => p [URI] [URI] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k URI URI) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [URI] [URI]) Source #

jsonOmitField :: Maybe (APrism' URI ()) Source #

Json Scientific Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Json Text Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p Text Text Source #

jsonList :: JsonVal p => p [Text] [Text] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k Text Text) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Text] [Text]) Source #

jsonOmitField :: Maybe (APrism' Text ()) Source #

Json Text Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p Text Text Source #

jsonList :: JsonVal p => p [Text] [Text] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k Text Text) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Text] [Text]) Source #

jsonOmitField :: Maybe (APrism' Text ()) Source #

Json ShortText Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Json CalendarDiffDays Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Json Day Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p Day Day Source #

jsonList :: JsonVal p => p [Day] [Day] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k Day Day) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Day] [Day]) Source #

jsonOmitField :: Maybe (APrism' Day ()) Source #

Json Month Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p Month Month Source #

jsonList :: JsonVal p => p [Month] [Month] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k Month Month) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Month] [Month]) Source #

jsonOmitField :: Maybe (APrism' Month ()) Source #

Json Quarter Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Json QuarterOfYear Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Json DayOfWeek Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Json DiffTime Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Json NominalDiffTime Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Json SystemTime Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Json UTCTime Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Json CalendarDiffTime Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Json LocalTime Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Json TimeOfDay Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Json ZonedTime Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Json UUID Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p UUID UUID Source #

jsonList :: JsonVal p => p [UUID] [UUID] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k UUID UUID) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [UUID] [UUID]) Source #

jsonOmitField :: Maybe (APrism' UUID ()) Source #

Json Integer Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Json Natural Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Json () Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p () () Source #

jsonList :: JsonVal p => p [()] [()] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k () ()) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [()] [()]) Source #

jsonOmitField :: Maybe (APrism' () ()) Source #

Json Bool Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p Bool Bool Source #

jsonList :: JsonVal p => p [Bool] [Bool] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k Bool Bool) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Bool] [Bool]) Source #

jsonOmitField :: Maybe (APrism' Bool ()) Source #

Json Char Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p Char Char Source #

jsonList :: JsonVal p => p [Char] [Char] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k Char Char) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Char] [Char]) Source #

jsonOmitField :: Maybe (APrism' Char ()) Source #

Json Double Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p Double Double Source #

jsonList :: JsonVal p => p [Double] [Double] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k Double Double) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Double] [Double]) Source #

jsonOmitField :: Maybe (APrism' Double ()) Source #

Json Float Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p Float Float Source #

jsonList :: JsonVal p => p [Float] [Float] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k Float Float) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Float] [Float]) Source #

jsonOmitField :: Maybe (APrism' Float ()) Source #

Json Int Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p Int Int Source #

jsonList :: JsonVal p => p [Int] [Int] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k Int Int) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Int] [Int]) Source #

jsonOmitField :: Maybe (APrism' Int ()) Source #

Json Word Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p Word Word Source #

jsonList :: JsonVal p => p [Word] [Word] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k Word Word) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Word] [Word]) Source #

jsonOmitField :: Maybe (APrism' Word ()) Source #

Json v => Json (KeyMap v) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (KeyMap v) (KeyMap v) Source #

jsonList :: JsonVal p => p [KeyMap v] [KeyMap v] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (KeyMap v) (KeyMap v)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [KeyMap v] [KeyMap v]) Source #

jsonOmitField :: Maybe (APrism' (KeyMap v) ()) Source #

Json a => Json (First a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (First a) (First a) Source #

jsonList :: JsonVal p => p [First a] [First a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (First a) (First a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [First a] [First a]) Source #

jsonOmitField :: Maybe (APrism' (First a) ()) Source #

Json a => Json (Last a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Last a) (Last a) Source #

jsonList :: JsonVal p => p [Last a] [Last a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Last a) (Last a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Last a] [Last a]) Source #

jsonOmitField :: Maybe (APrism' (Last a) ()) Source #

Json a => Json (Max a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Max a) (Max a) Source #

jsonList :: JsonVal p => p [Max a] [Max a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Max a) (Max a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Max a] [Max a]) Source #

jsonOmitField :: Maybe (APrism' (Max a) ()) Source #

Json a => Json (Min a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Min a) (Min a) Source #

jsonList :: JsonVal p => p [Min a] [Min a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Min a) (Min a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Min a] [Min a]) Source #

jsonOmitField :: Maybe (APrism' (Min a) ()) Source #

Json a => Json (WrappedMonoid a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Json a => Json (IntMap a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (IntMap a) (IntMap a) Source #

jsonList :: JsonVal p => p [IntMap a] [IntMap a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (IntMap a) (IntMap a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [IntMap a] [IntMap a]) Source #

jsonOmitField :: Maybe (APrism' (IntMap a) ()) Source #

Json a => Json (Seq a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Seq a) (Seq a) Source #

jsonList :: JsonVal p => p [Seq a] [Seq a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Seq a) (Seq a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Seq a] [Seq a]) Source #

jsonOmitField :: Maybe (APrism' (Seq a) ()) Source #

(Ord a, Json a) => Json (Set a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Set a) (Set a) Source #

jsonList :: JsonVal p => p [Set a] [Set a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Set a) (Set a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Set a] [Set a]) Source #

jsonOmitField :: Maybe (APrism' (Set a) ()) Source #

(Typeable a, Json a) => Json (Tree a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Tree a) (Tree a) Source #

jsonList :: JsonVal p => p [Tree a] [Tree a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Tree a) (Tree a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Tree a] [Tree a]) Source #

jsonOmitField :: Maybe (APrism' (Tree a) ()) Source #

(Typeable f, Json (f (Fix f))) => Json (Fix f) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Fix f) (Fix f) Source #

jsonList :: JsonVal p => p [Fix f] [Fix f] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Fix f) (Fix f)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Fix f] [Fix f]) Source #

jsonOmitField :: Maybe (APrism' (Fix f) ()) Source #

(Functor f, Typeable f, Json (f (Fix f))) => Json (Mu f) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Mu f) (Mu f) Source #

jsonList :: JsonVal p => p [Mu f] [Mu f] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Mu f) (Mu f)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Mu f] [Mu f]) Source #

jsonOmitField :: Maybe (APrism' (Mu f) ()) Source #

(Functor f, Typeable f, Json (f (Fix f))) => Json (Nu f) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Nu f) (Nu f) Source #

jsonList :: JsonVal p => p [Nu f] [Nu f] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Nu f) (Nu f)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Nu f] [Nu f]) Source #

jsonOmitField :: Maybe (APrism' (Nu f) ()) Source #

Json a => Json (DNonEmpty a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (DNonEmpty a) (DNonEmpty a) Source #

jsonList :: JsonVal p => p [DNonEmpty a] [DNonEmpty a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (DNonEmpty a) (DNonEmpty a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [DNonEmpty a] [DNonEmpty a]) Source #

jsonOmitField :: Maybe (APrism' (DNonEmpty a) ()) Source #

Json a => Json (DList a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (DList a) (DList a) Source #

jsonList :: JsonVal p => p [DList a] [DList a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (DList a) (DList a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [DList a] [DList a]) Source #

jsonOmitField :: Maybe (APrism' (DList a) ()) Source #

Json a => Json (NonEmpty a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (NonEmpty a) (NonEmpty a) Source #

jsonList :: JsonVal p => p [NonEmpty a] [NonEmpty a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (NonEmpty a) (NonEmpty a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [NonEmpty a] [NonEmpty a]) Source #

jsonOmitField :: Maybe (APrism' (NonEmpty a) ()) Source #

Json a => Json (Identity a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Identity a) (Identity a) Source #

jsonList :: JsonVal p => p [Identity a] [Identity a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Identity a) (Identity a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Identity a] [Identity a]) Source #

jsonOmitField :: Maybe (APrism' (Identity a) ()) Source #

Json a => Json (First a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (First a) (First a) Source #

jsonList :: JsonVal p => p [First a] [First a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (First a) (First a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [First a] [First a]) Source #

jsonOmitField :: Maybe (APrism' (First a) ()) Source #

Json a => Json (Last a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Last a) (Last a) Source #

jsonList :: JsonVal p => p [Last a] [Last a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Last a) (Last a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Last a] [Last a]) Source #

jsonOmitField :: Maybe (APrism' (Last a) ()) Source #

Json a => Json (Down a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Down a) (Down a) Source #

jsonList :: JsonVal p => p [Down a] [Down a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Down a) (Down a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Down a] [Down a]) Source #

jsonOmitField :: Maybe (APrism' (Down a) ()) Source #

Json a => Json (Dual a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Dual a) (Dual a) Source #

jsonList :: JsonVal p => p [Dual a] [Dual a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Dual a) (Dual a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Dual a] [Dual a]) Source #

jsonOmitField :: Maybe (APrism' (Dual a) ()) Source #

Json a => Json (Product a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Product a) (Product a) Source #

jsonList :: JsonVal p => p [Product a] [Product a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Product a) (Product a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Product a] [Product a]) Source #

jsonOmitField :: Maybe (APrism' (Product a) ()) Source #

Json a => Json (Sum a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Sum a) (Sum a) Source #

jsonList :: JsonVal p => p [Sum a] [Sum a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Sum a) (Sum a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Sum a] [Sum a]) Source #

jsonOmitField :: Maybe (APrism' (Sum a) ()) Source #

(Generic a, Rep a ~ D1 d f, GSum f, Typeable a, EnumTag (AllNullary f) a) => Json (Generically a) Source #

The Generic Json grammar, by aeson's default options.

Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Generically a) (Generically a) Source #

jsonList :: JsonVal p => p [Generically a] [Generically a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Generically a) (Generically a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Generically a] [Generically a]) Source #

jsonOmitField :: Maybe (APrism' (Generically a) ()) Source #

(Integral a, Json a) => Json (Ratio a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Ratio a) (Ratio a) Source #

jsonList :: JsonVal p => p [Ratio a] [Ratio a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Ratio a) (Ratio a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Ratio a] [Ratio a]) Source #

jsonOmitField :: Maybe (APrism' (Ratio a) ()) Source #

Json a => Json (Array a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Array a) (Array a) Source #

jsonList :: JsonVal p => p [Array a] [Array a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Array a) (Array a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Array a] [Array a]) Source #

jsonOmitField :: Maybe (APrism' (Array a) ()) Source #

(Prim a, Json a) => Json (PrimArray a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (PrimArray a) (PrimArray a) Source #

jsonList :: JsonVal p => p [PrimArray a] [PrimArray a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (PrimArray a) (PrimArray a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [PrimArray a] [PrimArray a]) Source #

jsonOmitField :: Maybe (APrism' (PrimArray a) ()) Source #

Json a => Json (SmallArray a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (SmallArray a) (SmallArray a) Source #

jsonList :: JsonVal p => p [SmallArray a] [SmallArray a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (SmallArray a) (SmallArray a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [SmallArray a] [SmallArray a]) Source #

jsonOmitField :: Maybe (APrism' (SmallArray a) ()) Source #

Json a => Json (Maybe a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Maybe a) (Maybe a) Source #

jsonList :: JsonVal p => p [Maybe a] [Maybe a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Maybe a) (Maybe a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Maybe a] [Maybe a]) Source #

jsonOmitField :: Maybe (APrism' (Maybe a) ()) Source #

(Eq a, Hashable a, Json a) => Json (HashSet a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (HashSet a) (HashSet a) Source #

jsonList :: JsonVal p => p [HashSet a] [HashSet a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (HashSet a) (HashSet a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [HashSet a] [HashSet a]) Source #

jsonOmitField :: Maybe (APrism' (HashSet a) ()) Source #

Json a => Json (Vector a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Vector a) (Vector a) Source #

jsonList :: JsonVal p => p [Vector a] [Vector a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Vector a) (Vector a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Vector a] [Vector a]) Source #

jsonOmitField :: Maybe (APrism' (Vector a) ()) Source #

(Prim a, Json a) => Json (Vector a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Vector a) (Vector a) Source #

jsonList :: JsonVal p => p [Vector a] [Vector a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Vector a) (Vector a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Vector a] [Vector a]) Source #

jsonOmitField :: Maybe (APrism' (Vector a) ()) Source #

(Storable a, Json a) => Json (Vector a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Vector a) (Vector a) Source #

jsonList :: JsonVal p => p [Vector a] [Vector a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Vector a) (Vector a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Vector a] [Vector a]) Source #

jsonOmitField :: Maybe (APrism' (Vector a) ()) Source #

(Unbox a, Json a) => Json (Vector a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Vector a) (Vector a) Source #

jsonList :: JsonVal p => p [Vector a] [Vector a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Vector a) (Vector a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Vector a] [Vector a]) Source #

jsonOmitField :: Maybe (APrism' (Vector a) ()) Source #

Json a => Json (Maybe a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Maybe a) (Maybe a) Source #

jsonList :: JsonVal p => p [Maybe a] [Maybe a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Maybe a) (Maybe a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Maybe a] [Maybe a]) Source #

jsonOmitField :: Maybe (APrism' (Maybe a) ()) Source #

Json a => Json (Solo a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Solo a) (Solo a) Source #

jsonList :: JsonVal p => p [Solo a] [Solo a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Solo a) (Solo a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Solo a] [Solo a]) Source #

jsonOmitField :: Maybe (APrism' (Solo a) ()) Source #

Json a => Json [a] Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p [a] [a] Source #

jsonList :: JsonVal p => p [[a]] [[a]] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [a] [a]) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [[a]] [[a]]) Source #

jsonOmitField :: Maybe (APrism' [a] ()) Source #

HasResolution a => Json (Fixed a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Fixed a) (Fixed a) Source #

jsonList :: JsonVal p => p [Fixed a] [Fixed a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Fixed a) (Fixed a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Fixed a] [Fixed a]) Source #

jsonOmitField :: Maybe (APrism' (Fixed a) ()) Source #

(Ord k, Json k, Json v) => Json (Map k v) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Map k v) (Map k v) Source #

jsonList :: JsonVal p => p [Map k v] [Map k v] Source #

jsonKey :: Maybe (forall (k0 :: Type -> Type -> Type). JsonStr k0 => k0 (Map k v) (Map k v)) Source #

jsonKeyList :: Maybe (forall (k0 :: Type -> Type -> Type). JsonStr k0 => k0 [Map k v] [Map k v]) Source #

jsonOmitField :: Maybe (APrism' (Map k v) ()) Source #

(Json a, Json b) => Json (Either a b) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Either a b) (Either a b) Source #

jsonList :: JsonVal p => p [Either a b] [Either a b] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Either a b) (Either a b)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Either a b] [Either a b]) Source #

jsonOmitField :: Maybe (APrism' (Either a b) ()) Source #

Json (Proxy a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Proxy a) (Proxy a) Source #

jsonList :: JsonVal p => p [Proxy a] [Proxy a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Proxy a) (Proxy a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Proxy a] [Proxy a]) Source #

jsonOmitField :: Maybe (APrism' (Proxy a) ()) Source #

(Json a, Json b) => Json (Either a b) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Either a b) (Either a b) Source #

jsonList :: JsonVal p => p [Either a b] [Either a b] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Either a b) (Either a b)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Either a b] [Either a b]) Source #

jsonOmitField :: Maybe (APrism' (Either a b) ()) Source #

(Json a, Json b) => Json (These a b) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (These a b) (These a b) Source #

jsonList :: JsonVal p => p [These a b] [These a b] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (These a b) (These a b)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [These a b] [These a b]) Source #

jsonOmitField :: Maybe (APrism' (These a b) ()) Source #

(Json a, Json b) => Json (Pair a b) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Pair a b) (Pair a b) Source #

jsonList :: JsonVal p => p [Pair a b] [Pair a b] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Pair a b) (Pair a b)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Pair a b] [Pair a b]) Source #

jsonOmitField :: Maybe (APrism' (Pair a b) ()) Source #

(Json a, Json b) => Json (These a b) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (These a b) (These a b) Source #

jsonList :: JsonVal p => p [These a b] [These a b] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (These a b) (These a b)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [These a b] [These a b]) Source #

jsonOmitField :: Maybe (APrism' (These a b) ()) Source #

(Eq k, Hashable k, Json k, Json v) => Json (HashMap k v) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (HashMap k v) (HashMap k v) Source #

jsonList :: JsonVal p => p [HashMap k v] [HashMap k v] Source #

jsonKey :: Maybe (forall (k0 :: Type -> Type -> Type). JsonStr k0 => k0 (HashMap k v) (HashMap k v)) Source #

jsonKeyList :: Maybe (forall (k0 :: Type -> Type -> Type). JsonStr k0 => k0 [HashMap k v] [HashMap k v]) Source #

jsonOmitField :: Maybe (APrism' (HashMap k v) ()) Source #

(Json a, Json b) => Json (a, b) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (a, b) (a, b) Source #

jsonList :: JsonVal p => p [(a, b)] [(a, b)] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (a, b) (a, b)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [(a, b)] [(a, b)]) Source #

jsonOmitField :: Maybe (APrism' (a, b) ()) Source #

Json a => Json (Const a b) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Const a b) (Const a b) Source #

jsonList :: JsonVal p => p [Const a b] [Const a b] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Const a b) (Const a b)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Const a b] [Const a b]) Source #

jsonOmitField :: Maybe (APrism' (Const a b) ()) Source #

Json b => Json (Tagged a b) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Tagged a b) (Tagged a b) Source #

jsonList :: JsonVal p => p [Tagged a b] [Tagged a b] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Tagged a b) (Tagged a b)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Tagged a b] [Tagged a b]) Source #

jsonOmitField :: Maybe (APrism' (Tagged a b) ()) Source #

(Json (f a), Json (g a)) => Json (These1 f g a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (These1 f g a) (These1 f g a) Source #

jsonList :: JsonVal p => p [These1 f g a] [These1 f g a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (These1 f g a) (These1 f g a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [These1 f g a] [These1 f g a]) Source #

jsonOmitField :: Maybe (APrism' (These1 f g a) ()) Source #

(Json a, Json b, Json c) => Json (a, b, c) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (a, b, c) (a, b, c) Source #

jsonList :: JsonVal p => p [(a, b, c)] [(a, b, c)] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (a, b, c) (a, b, c)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [(a, b, c)] [(a, b, c)]) Source #

jsonOmitField :: Maybe (APrism' (a, b, c) ()) Source #

(Json (f a), Json (g a)) => Json (Product f g a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Product f g a) (Product f g a) Source #

jsonList :: JsonVal p => p [Product f g a] [Product f g a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Product f g a) (Product f g a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Product f g a] [Product f g a]) Source #

jsonOmitField :: Maybe (APrism' (Product f g a) ()) Source #

(Json (f a), Json (g a)) => Json (Sum f g a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Sum f g a) (Sum f g a) Source #

jsonList :: JsonVal p => p [Sum f g a] [Sum f g a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Sum f g a) (Sum f g a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Sum f g a] [Sum f g a]) Source #

jsonOmitField :: Maybe (APrism' (Sum f g a) ()) Source #

(Json a, Json b, Json c, Json d) => Json (a, b, c, d) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (a, b, c, d) (a, b, c, d) Source #

jsonList :: JsonVal p => p [(a, b, c, d)] [(a, b, c, d)] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (a, b, c, d) (a, b, c, d)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [(a, b, c, d)] [(a, b, c, d)]) Source #

jsonOmitField :: Maybe (APrism' (a, b, c, d) ()) Source #

Json (f (g a)) => Json (Compose f g a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (Compose f g a) (Compose f g a) Source #

jsonList :: JsonVal p => p [Compose f g a] [Compose f g a] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (Compose f g a) (Compose f g a)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [Compose f g a] [Compose f g a]) Source #

jsonOmitField :: Maybe (APrism' (Compose f g a) ()) Source #

(Json a, Json b, Json c, Json d, Json e) => Json (a, b, c, d, e) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (a, b, c, d, e) (a, b, c, d, e) Source #

jsonList :: JsonVal p => p [(a, b, c, d, e)] [(a, b, c, d, e)] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (a, b, c, d, e) (a, b, c, d, e)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [(a, b, c, d, e)] [(a, b, c, d, e)]) Source #

jsonOmitField :: Maybe (APrism' (a, b, c, d, e) ()) Source #

(Json a, Json b, Json c, Json d, Json e, Json f) => Json (a, b, c, d, e, f) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (a, b, c, d, e, f) (a, b, c, d, e, f) Source #

jsonList :: JsonVal p => p [(a, b, c, d, e, f)] [(a, b, c, d, e, f)] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (a, b, c, d, e, f) (a, b, c, d, e, f)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [(a, b, c, d, e, f)] [(a, b, c, d, e, f)]) Source #

jsonOmitField :: Maybe (APrism' (a, b, c, d, e, f) ()) Source #

(Json a, Json b, Json c, Json d, Json e, Json f, Json g) => Json (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (a, b, c, d, e, f, g) (a, b, c, d, e, f, g) Source #

jsonList :: JsonVal p => p [(a, b, c, d, e, f, g)] [(a, b, c, d, e, f, g)] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (a, b, c, d, e, f, g) (a, b, c, d, e, f, g)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [(a, b, c, d, e, f, g)] [(a, b, c, d, e, f, g)]) Source #

jsonOmitField :: Maybe (APrism' (a, b, c, d, e, f, g) ()) Source #

(Json a, Json b, Json c, Json d, Json e, Json f, Json g, Json h) => Json (a, b, c, d, e, f, g, h) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (a, b, c, d, e, f, g, h) (a, b, c, d, e, f, g, h) Source #

jsonList :: JsonVal p => p [(a, b, c, d, e, f, g, h)] [(a, b, c, d, e, f, g, h)] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (a, b, c, d, e, f, g, h) (a, b, c, d, e, f, g, h)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [(a, b, c, d, e, f, g, h)] [(a, b, c, d, e, f, g, h)]) Source #

jsonOmitField :: Maybe (APrism' (a, b, c, d, e, f, g, h) ()) Source #

(Json a, Json b, Json c, Json d, Json e, Json f, Json g, Json h, Json i) => Json (a, b, c, d, e, f, g, h, i) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (a, b, c, d, e, f, g, h, i) (a, b, c, d, e, f, g, h, i) Source #

jsonList :: JsonVal p => p [(a, b, c, d, e, f, g, h, i)] [(a, b, c, d, e, f, g, h, i)] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (a, b, c, d, e, f, g, h, i) (a, b, c, d, e, f, g, h, i)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [(a, b, c, d, e, f, g, h, i)] [(a, b, c, d, e, f, g, h, i)]) Source #

jsonOmitField :: Maybe (APrism' (a, b, c, d, e, f, g, h, i) ()) Source #

(Json a, Json b, Json c, Json d, Json e, Json f, Json g, Json h, Json i, Json j) => Json (a, b, c, d, e, f, g, h, i, j) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (a, b, c, d, e, f, g, h, i, j) (a, b, c, d, e, f, g, h, i, j) Source #

jsonList :: JsonVal p => p [(a, b, c, d, e, f, g, h, i, j)] [(a, b, c, d, e, f, g, h, i, j)] Source #

jsonKey :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k (a, b, c, d, e, f, g, h, i, j) (a, b, c, d, e, f, g, h, i, j)) Source #

jsonKeyList :: Maybe (forall (k :: Type -> Type -> Type). JsonStr k => k [(a, b, c, d, e, f, g, h, i, j)] [(a, b, c, d, e, f, g, h, i, j)]) Source #

jsonOmitField :: Maybe (APrism' (a, b, c, d, e, f, g, h, i, j) ()) Source #

(Json a, Json b, Json c, Json d, Json e, Json f, Json g, Json h, Json i, Json j, Json k) => Json (a, b, c, d, e, f, g, h, i, j, k) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (a, b, c, d, e, f, g, h, i, j, k) (a, b, c, d, e, f, g, h, i, j, k) Source #

jsonList :: JsonVal p => p [(a, b, c, d, e, f, g, h, i, j, k)] [(a, b, c, d, e, f, g, h, i, j, k)] Source #

jsonKey :: Maybe (forall (k0 :: Type -> Type -> Type). JsonStr k0 => k0 (a, b, c, d, e, f, g, h, i, j, k) (a, b, c, d, e, f, g, h, i, j, k)) Source #

jsonKeyList :: Maybe (forall (k0 :: Type -> Type -> Type). JsonStr k0 => k0 [(a, b, c, d, e, f, g, h, i, j, k)] [(a, b, c, d, e, f, g, h, i, j, k)]) Source #

jsonOmitField :: Maybe (APrism' (a, b, c, d, e, f, g, h, i, j, k) ()) Source #

(Json a, Json b, Json c, Json d, Json e, Json f, Json g, Json h, Json i, Json j, Json k, Json l) => Json (a, b, c, d, e, f, g, h, i, j, k, l) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (a, b, c, d, e, f, g, h, i, j, k, l) (a, b, c, d, e, f, g, h, i, j, k, l) Source #

jsonList :: JsonVal p => p [(a, b, c, d, e, f, g, h, i, j, k, l)] [(a, b, c, d, e, f, g, h, i, j, k, l)] Source #

jsonKey :: Maybe (forall (k0 :: Type -> Type -> Type). JsonStr k0 => k0 (a, b, c, d, e, f, g, h, i, j, k, l) (a, b, c, d, e, f, g, h, i, j, k, l)) Source #

jsonKeyList :: Maybe (forall (k0 :: Type -> Type -> Type). JsonStr k0 => k0 [(a, b, c, d, e, f, g, h, i, j, k, l)] [(a, b, c, d, e, f, g, h, i, j, k, l)]) Source #

jsonOmitField :: Maybe (APrism' (a, b, c, d, e, f, g, h, i, j, k, l) ()) Source #

(Json a, Json b, Json c, Json d, Json e, Json f, Json g, Json h, Json i, Json j, Json k, Json l, Json m) => Json (a, b, c, d, e, f, g, h, i, j, k, l, m) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (a, b, c, d, e, f, g, h, i, j, k, l, m) (a, b, c, d, e, f, g, h, i, j, k, l, m) Source #

jsonList :: JsonVal p => p [(a, b, c, d, e, f, g, h, i, j, k, l, m)] [(a, b, c, d, e, f, g, h, i, j, k, l, m)] Source #

jsonKey :: Maybe (forall (k0 :: Type -> Type -> Type). JsonStr k0 => k0 (a, b, c, d, e, f, g, h, i, j, k, l, m) (a, b, c, d, e, f, g, h, i, j, k, l, m)) Source #

jsonKeyList :: Maybe (forall (k0 :: Type -> Type -> Type). JsonStr k0 => k0 [(a, b, c, d, e, f, g, h, i, j, k, l, m)] [(a, b, c, d, e, f, g, h, i, j, k, l, m)]) Source #

jsonOmitField :: Maybe (APrism' (a, b, c, d, e, f, g, h, i, j, k, l, m) ()) Source #

(Json a, Json b, Json c, Json d, Json e, Json f, Json g, Json h, Json i, Json j, Json k, Json l, Json m, Json n) => Json (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (a, b, c, d, e, f, g, h, i, j, k, l, m, n) (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source #

jsonList :: JsonVal p => p [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)] [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)] Source #

jsonKey :: Maybe (forall (k0 :: Type -> Type -> Type). JsonStr k0 => k0 (a, b, c, d, e, f, g, h, i, j, k, l, m, n) (a, b, c, d, e, f, g, h, i, j, k, l, m, n)) Source #

jsonKeyList :: Maybe (forall (k0 :: Type -> Type -> Type). JsonStr k0 => k0 [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)] [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)]) Source #

jsonOmitField :: Maybe (APrism' (a, b, c, d, e, f, g, h, i, j, k, l, m, n) ()) Source #

(Json a, Json b, Json c, Json d, Json e, Json f, Json g, Json h, Json i, Json j, Json k, Json l, Json m, Json n, Json o) => Json (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

json :: JsonVal p => p (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source #

jsonList :: JsonVal p => p [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)] [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)] Source #

jsonKey :: Maybe (forall (k0 :: Type -> Type -> Type). JsonStr k0 => k0 (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)) Source #

jsonKeyList :: Maybe (forall (k0 :: Type -> Type -> Type). JsonStr k0 => k0 [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)] [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)]) Source #

jsonOmitField :: Maybe (APrism' (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) ()) Source #

jsonGeneric :: forall a (d :: Meta) (f :: Type -> Type) p. (Generic a, Rep a ~ D1 d f, GSum f, Typeable a, EnumTag (AllNullary f) a, JsonVal p) => Options -> p a a Source #

The Generic Json grammar by aeson's Options, compatible with aeson's generic instances by the same options, defined as a rule named by its Typeable type, so that each instantiation of a parametric type is its own (possibly recursive) definition.

jsonDecode :: Json a => ByteString -> Either JsonError a Source #

eitherDecode, which reads the JSON text by aeson, failing by its message for text which isn't JSON.

jsonErrorPrint :: Json a => a -> Either JsonError Value Source #

jsonPrint, failing where the grammar doesn't print a value, like a key which repeats.

>>> jsonErrorPrint (1 :: Int)
Right (Number 1.0)

jsonErrorEncode :: Json a => a -> Either JsonError Encoding Source #

jsonEncode, failing where the grammar doesn't print a value.

newtype ViaJson a Source #

aeson's instances, derived from a Json instance, failing to parse at the path of a JsonError, by its message: ToJSON & FromJSON, with their fields omitted by jsonOmitField, & ToJSONKey & FromJSONKey, by jsonKey & jsonKeyList, or else as values, in arrays of pairs.

data Point = Point {x :: Int, y :: Int}
  deriving stock Generic
  deriving anyclass Json
  deriving (ToJSON, FromJSON) via ViaJson Point

Constructors

ViaJson a 

Instances

Instances details
Json a => FromJSON (ViaJson a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Json a => FromJSONKey (ViaJson a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Json a => ToJSON (ViaJson a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Json a => ToJSONKey (ViaJson a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Show a => Show (ViaJson a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

showsPrec :: Int -> ViaJson a -> ShowS #

show :: ViaJson a -> String #

showList :: [ViaJson a] -> ShowS #

Eq a => Eq (ViaJson a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

(==) :: ViaJson a -> ViaJson a -> Bool #

(/=) :: ViaJson a -> ViaJson a -> Bool #

Ord a => Ord (ViaJson a) Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Methods

compare :: ViaJson a -> ViaJson a -> Ordering #

(<) :: ViaJson a -> ViaJson a -> Bool #

(<=) :: ViaJson a -> ViaJson a -> Bool #

(>) :: ViaJson a -> ViaJson a -> Bool #

(>=) :: ViaJson a -> ViaJson a -> Bool #

max :: ViaJson a -> ViaJson a -> ViaJson a #

min :: ViaJson a -> ViaJson a -> ViaJson a #

Grammar

class (CocartesianChoice p, Filtrator p, JsonStr p) => JsonVal (p :: Type -> Type -> Type) where Source #

JsonVal grammars describe JSON values: null, booleans, numbers, strings, by JsonStr, arrays & objects, by JsonTup & JsonObj. As CocartesianChoices & Filtrators, they have alternatives (>+<, >|<) & partial isomorphisms (>?, ?<). Its numbers are bounded, & its integers integral, as aeson's are.

Minimal complete definition

jsonNull, jsonBool, jsonNumber, jsonTuple, jsonObject

Methods

jsonNull :: p () () Source #

jsonBool :: p Bool Bool Source #

jsonNumber :: p Scientific Scientific Source #

jsonInt :: p Int Int Source #

jsonInt8 :: p Int8 Int8 Source #

jsonInt16 :: p Int16 Int16 Source #

jsonInt32 :: p Int32 Int32 Source #

jsonInt64 :: p Int64 Int64 Source #

jsonWord :: p Word Word Source #

jsonWord8 :: p Word8 Word8 Source #

jsonWord16 :: p Word16 Word16 Source #

jsonWord32 :: p Word32 Word32 Source #

jsonWord64 :: p Word64 Word64 Source #

jsonInteger :: p Integer Integer Source #

jsonNatural :: p Natural Natural Source #

jsonDouble :: p Double Double Source #

jsonArray :: p a b -> p [a] [b] Source #

A homogeneous JSON array, like TypeScript's T[], which is a tuple of a rest element, though interpreters may define it more efficiently.

jsonArray p = jsonTuple (manyP (jsonElem p))

jsonNullable :: p a b -> p (Maybe a) (Maybe b) Source #

null or a value, like aeson's Maybe, though interpreters may define it more efficiently.

jsonNullable p = eotMaybe >~ jsonNull >+< p

jsonPair :: p a b -> p c d -> p (a, c) (b, d) Source #

A pair, as an array of its two elements, though interpreters may define it more efficiently.

jsonPair p q = jsonTuple (jsonElem p >*< jsonElem q)

jsonTag :: Text -> p a b -> p a b Source #

An object of a single property, as aeson tags Either's & sums' values, though interpreters may define it more efficiently.

jsonTag k p = jsonObjectStrict (k !: p)

jsonMap :: Ord b => (forall (k :: Type -> Type -> Type). JsonStr k => k a b) -> p c d -> p (Map a c) (Map b d) Source #

A jsonDict object of a Map, whose keys can't repeat, so that printing needn't check them.

jsonHashMap :: (Eq b, Hashable b) => (forall (k :: Type -> Type -> Type). JsonStr k => k a b) -> p c d -> p (HashMap a c) (HashMap b d) Source #

A jsonDict object of a HashMap, whose keys can't repeat, so that printing needn't check them.

jsonTuple :: (forall (q :: Type -> Type -> Type). JsonTup p q => q a b) -> p a b Source #

jsonObject :: (forall (q :: Type -> Type -> Type). JsonObj p q => q a b) -> p a b Source #

jsonObjectStrict :: (forall (q :: Type -> Type -> Type). JsonObj p q => q a b) -> p a b Source #

A jsonObject which rejects the properties that it doesn't name.

jsonValue :: p Value Value Source #

jsonTyped :: (Typeable a, JsonStr p) => p a a -> p a a Source #

A rule for a Haskell type, like a type definition, named by its Typeable type, so that each type's rule is its own.

Rule names follow a convention: a module-qualified word, like M.N.x, names a definition by its qualified name, and displays it unqualified, as x, in error messages & TypeScript, whenever that's unambiguous. So a type's rule is named by its fully qualified type, such as Data.Map.Internal.Map Data.Text.Internal.Text GHC.Types.Int, displayed as Map Text Int.

class (Monoidal q, CocartesianChoice q) => JsonObj (p :: Type -> Type -> Type) (q :: Type -> Type -> Type) | q -> p where Source #

JsonObj grammars describe the properties of a JSON object. Each key may be read or written at most once. A required property, k !: v, is like TypeScript's {k: T}, and an optional property, k ?: v, may be missing, like {k?: T}. A property with a default, "limit" ?: jsonInt != 10, like aeson's .:? & .!=, is missing exactly when it's the default. Its properties are JsonVal grammars, which determine its type.

Methods

(!:) :: Text -> p a b -> q a b infixr 7 Source #

(?:) :: Text -> p a b -> q (Maybe a) (Maybe b) infixr 7 Source #

jsonDict :: (forall (k :: Type -> Type -> Type). JsonStr k => k a b) -> p c d -> q [(a, c)] [(b, d)] Source #

The properties of an object which aren't named by !: or ?:, as a list of key-value pairs, by a grammar of keys & a grammar of values.

On its own, it's a dictionary.

jsonObject (jsonDict jsonText json)
-- {"a": 1, "b": 2}  <->  [("a", 1), ("b", 2)]

Beside named properties, it's the rest of them.

jsonObject ("id" !: json >*< jsonDict jsonText json)
-- {"id": 1, "a": true, "b": false}  <->  (1, [("a", True), ("b", False)])

Parsing fails unless every remaining property matches both grammars, so a narrower key grammar than jsonText, like jsonEnumWith, restricts the keys allowed. Printing fails on a key which repeats, or which is also named. An object has at most one jsonDict.

In TypeScript, it's an index signature, { [key: string]: T }, or, of an enumeration of keys, a mapped type, { [key in K]?: T }.

(!=) infix 6 #

Arguments

:: (Eq a, Profunctor q) 
=> q (Maybe a) (Maybe a)

optional

-> a

default

-> q a a 

An optional value, missing exactly when it's the default, like !=, by the non isomorphism.

prop> optP != def = non def ~< optP

class Alternator q => JsonTup (p :: Type -> Type -> Type) (q :: Type -> Type -> Type) | q -> p where Source #

JsonTup grammars describe the elements of a JSON array. As Alternators they have optional elements (optionalP, optionP), rest elements (manyP, someP) and alternatives (>+<, >|<), like TypeScript's variadic tuple types, [A, B?, ...C[]]. Its elements are JsonVal grammars, which determine its type.

Methods

jsonElem :: p a b -> q a b Source #

class (Cochoice p, forall x y. (x ~ (), y ~ ()) => IsString (p x y), forall x y. BackusNaurForm (p x y)) => JsonStr (p :: Type -> Type -> Type) where Source #

fromString s = only s ?< jsonString
jsonString = iso Text.pack Text.unpack >~ jsonText

Minimal complete definition

jsonText

Methods

jsonText :: p Text Text Source #

jsonString :: p String String Source #

jsonEncodedText :: APrism Text (Text, Encoding' Text) a a -> p a a Source #

A string matched from its Text, which is reviewed lazily as both its Text & an aeson string Encoding', either of which an interpreter uses.

jsonEnumWith :: (a -> Int) -> [(Text, a)] -> p a a Source #

An enumeration of strings, which a map's key may be, like TypeScript's union of string literals, "a" | "b", by a table of strings & their values, & the index of each value in it, so that printing needn't search it.

jsonEnum :: JsonStr p => AComonocle a a () () -> (a -> Text) -> p a a Source #

An enumeration of strings, by AComonocle's copies & their names, which jsonEnumWith tables once, numbered as fromEnumerable numbers them.

>>> import Control.Lens (coerced)
>>> import Control.Lens.Comonocle (_BoundedEnum)
>>> import Data.Text qualified as Text
>>> newtype Order = Order Ordering deriving (Show)
>>> let name = Text.toLower . Text.pack . show @Ordering
>>> instance Json Order where json = coerced >~ jsonEnum _BoundedEnum name
>>> jsonPrint (Order GT)
String "gt"
>>> jsonParse @Order (Aeson.String "lt")
Right (Order LT)

Types

jsonType :: forall a -> Json a => Bnf JsonType Source #

The type of the JSON of a type, by its rules, which are named by their qualified names.

>>> jsonType (type Bool)
Bnf {startBnf = JsonBoolean, rulesBnf = fromList []}
>>> jsonType (Maybe Ordering)
Bnf {startBnf = JsonUnion [JsonNull,JsonRule "GHC.Types.Ordering"], rulesBnf = fromList [("GHC.Types.Ordering",JsonUnion [JsonLiteral "LT",JsonLiteral "EQ",JsonLiteral "GT"])]}

jsonTsDeclarations :: forall (as :: [Type]) -> All Json as => [TsDeclaration] Source #

Type the JSON of types, in TypeScript, as a declaration of each rule of their types, named by its unqualified name, or else its qualified name, which jsonTsPut puts.

>>> jsonTsDeclarations (type '[Maybe Ordering])
[TypeAliasDeclaration [ExportKeyword] "Ordering" [] (UnionType [LiteralType (TextLiteral "LT"),LiteralType (TextLiteral "EQ"),LiteralType (TextLiteral "GT")])]

jsonTsPut :: forall (as :: [Type]) -> All Json as => Handle -> IO () Source #

Put the TypeScript declarations of the JSON of types to a handle, like a .ts file.

>>> jsonTsPut (type '[Maybe Ordering]) stdout
export type Ordering = "LT" | "EQ" | "GT";

data JsonType Source #

The type of JSON values, which a grammar describes, of rules by their names, in a Bnf, as jsonType describes them. It's the union of its alternatives, so that falseP is the type of no values.

Constructors

JsonRule String

the type of a rule, by its name

JsonNull
null
JsonBoolean

true or false

JsonNumber

numbers

JsonString

strings

JsonLiteral Text

a string

JsonSubtype JsonType

some values of a type

JsonArray JsonElements

arrays of elements

JsonObject [JsonProperty]

objects of properties

JsonUnion [JsonType]

values of any of some types

data JsonElements Source #

The JsonElements of a JsonArray are the KleeneStarAlgebra generated by JsonType.

Constructors

JsonElement JsonType

an element

JsonElements JsonElements

elements, repeated any number of times

JsonElements1 JsonElements

elements, repeated at least once

JsonElementsOpt JsonElements

elements, or none

JsonElementsTup [JsonElements]

elements, in sequence

JsonElementsAlt [JsonElements]

elements, any of some alternatives

Instances

Instances details
DisjunctiveMonoid JsonElements Source # 
Instance details

Defined in Control.Lens.Grammar.Json

KleeneStarAlgebra JsonElements Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Monoid JsonElements Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Semigroup JsonElements Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Read JsonElements Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Show JsonElements Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Eq JsonElements Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Ord JsonElements Source # 
Instance details

Defined in Control.Lens.Grammar.Json

data JsonProperty Source #

A property of a JsonObject.

Constructors

JsonProperty Text Bool JsonType

a property, by its key, which is optional or not

JsonDict JsonType JsonType

the rest of the properties, by the types of their keys & values

Errors

data JsonError Source #

A located failure to decode, parse or print a Value. Its path is relative to that Value, root first. It expected one of the alternatives, none meaning just "unexpected". Parsing found a Value, or decoding found text which isn't JSON, by aeson's message; printing doesn't show the Haskell value it found. It failed within rules, outermost first, branching where alternatives failed alike; a rule it failed for as a whole is its expectation instead.

Instances

Instances details
Show JsonError Source # 
Instance details

Defined in Control.Lens.Grammar.Json

Eq JsonError Source # 
Instance details

Defined in Control.Lens.Grammar.Json

data JsonErrorSort Source #

How a JsonError failed, so that alternatives report the closest.

Constructors

JsonIlliteral

a string literal mismatch; the alternative doesn't apply

JsonMismatch

the value was rejected as a whole

JsonMissing

the value was rejected for what it contains, lacks or repeats

jsonErrorMessage :: JsonError -> String Source #

The message of a JsonError, without its path, as aeson words it.

>>> either jsonErrorMessage show (jsonParse @Bool (Aeson.String "yes"))
"expected boolean, but found \"yes\""