canonical-json-0.5.0.1: Canonical JSON for signing and hashing JSON values

Copyright(c) Edsko de Vries Duncan Coutts 2015
Safe HaskellNone
LanguageHaskell2010

Text.JSON.Canonical.Class

Contents

Description

Type classes and utilities for converting to and from JSValue.

Synopsis

Type classes

class ToJSON m a where Source #

Minimal complete definition

toJSON

Methods

toJSON :: a -> m JSValue Source #

Instances
Monad m => ToJSON m Int54 Source # 
Instance details

Defined in Text.JSON.Canonical.Class

Methods

toJSON :: Int54 -> m JSValue Source #

Monad m => ToJSON m String Source # 
Instance details

Defined in Text.JSON.Canonical.Class

Methods

toJSON :: String -> m JSValue Source #

Monad m => ToJSON m JSValue Source # 
Instance details

Defined in Text.JSON.Canonical.Class

Methods

toJSON :: JSValue -> m JSValue Source #

(Monad m, ToJSON m a) => ToJSON m [a] Source # 
Instance details

Defined in Text.JSON.Canonical.Class

Methods

toJSON :: [a] -> m JSValue Source #

(Monad m, ToObjectKey m k, ToJSON m a) => ToJSON m (Map k a) Source # 
Instance details

Defined in Text.JSON.Canonical.Class

Methods

toJSON :: Map k a -> m JSValue Source #

class FromJSON m a where Source #

Minimal complete definition

fromJSON

Methods

fromJSON :: JSValue -> m a Source #

Instances
ReportSchemaErrors m => FromJSON m Int54 Source # 
Instance details

Defined in Text.JSON.Canonical.Class

Methods

fromJSON :: JSValue -> m Int54 Source #

ReportSchemaErrors m => FromJSON m String Source # 
Instance details

Defined in Text.JSON.Canonical.Class

Methods

fromJSON :: JSValue -> m String Source #

Monad m => FromJSON m JSValue Source # 
Instance details

Defined in Text.JSON.Canonical.Class

(ReportSchemaErrors m, FromJSON m a) => FromJSON m [a] Source # 
Instance details

Defined in Text.JSON.Canonical.Class

Methods

fromJSON :: JSValue -> m [a] Source #

(ReportSchemaErrors m, Ord k, FromObjectKey m k, FromJSON m a) => FromJSON m (Map k a) Source # 
Instance details

Defined in Text.JSON.Canonical.Class

Methods

fromJSON :: JSValue -> m (Map k a) Source #

class ToObjectKey m a where Source #

Used in the ToJSON instance for Map

Minimal complete definition

toObjectKey

Methods

toObjectKey :: a -> m String Source #

Instances
Monad m => ToObjectKey m String Source # 
Instance details

Defined in Text.JSON.Canonical.Class

class FromObjectKey m a where Source #

Used in the FromJSON instance for Map

Minimal complete definition

fromObjectKey

Methods

fromObjectKey :: String -> m (Maybe a) Source #

Instances
Monad m => FromObjectKey m String Source # 
Instance details

Defined in Text.JSON.Canonical.Class

class (Applicative m, Monad m) => ReportSchemaErrors m where Source #

Monads in which we can report schema errors

Minimal complete definition

expected

Methods

expected :: Expected -> Maybe Got -> m a Source #

Utility

fromJSField :: (ReportSchemaErrors m, FromJSON m a) => JSValue -> String -> m a Source #

Extract a field from a JSON object

mkObject :: forall m. Monad m => [(String, m JSValue)] -> m JSValue Source #