autolib-transport
Safe HaskellSafe-Inferred
LanguageHaskell98

Data.Autolib.Transport

Description

Transport abstraction layer.

This library provides a common interface for representing data as JSON or XML-Rpc data. The common structure is captured in the Trans type.

To use it you'll need one of the backend implementations, JSON or HaXR.

Synopsis

Documentation

class ToTransport a where Source #

Conversion between data and intermediate representation.

Minimal complete definition

Nothing

Methods

toTransport :: Atom atom => a -> Trans atom Source #

Convert data to intermediate representation.

default toTransport :: (Generic a, GToTransport (Rep a), Atom atom) => a -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error a Source #

Convert intermediate representation to data.

default fromTransport :: (Generic a, GFromTransport (Rep a), Atom atom) => Trans atom -> Error a Source #

toTransportList :: Atom atom => [a] -> Trans atom Source #

This is analoguous to showList, used for the String instance.

fromTransportList :: Atom atom => Trans atom -> Error [a] Source #

This is analoguous to readList, used for the String instance.

Instances

Instances details
ToTransport ByteString Source # 
Instance details

Defined in Data.Autolib.Transport

ToTransport Text Source # 
Instance details

Defined in Data.Autolib.Transport

Methods

toTransport :: Atom atom => Text -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error Text Source #

toTransportList :: Atom atom => [Text] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [Text] Source #

ToTransport Integer Source # 
Instance details

Defined in Data.Autolib.Transport

Methods

toTransport :: Atom atom => Integer -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error Integer Source #

toTransportList :: Atom atom => [Integer] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [Integer] Source #

ToTransport () Source # 
Instance details

Defined in Data.Autolib.Transport

Methods

toTransport :: Atom atom => () -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error () Source #

toTransportList :: Atom atom => [()] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [()] Source #

ToTransport Bool Source # 
Instance details

Defined in Data.Autolib.Transport

Methods

toTransport :: Atom atom => Bool -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error Bool Source #

toTransportList :: Atom atom => [Bool] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [Bool] Source #

ToTransport Char Source # 
Instance details

Defined in Data.Autolib.Transport

Methods

toTransport :: Atom atom => Char -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error Char Source #

toTransportList :: Atom atom => [Char] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [Char] Source #

ToTransport Double Source # 
Instance details

Defined in Data.Autolib.Transport

Methods

toTransport :: Atom atom => Double -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error Double Source #

toTransportList :: Atom atom => [Double] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [Double] Source #

ToTransport Int Source # 
Instance details

Defined in Data.Autolib.Transport

Methods

toTransport :: Atom atom => Int -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error Int Source #

toTransportList :: Atom atom => [Int] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [Int] Source #

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

Defined in Data.Autolib.Transport

Methods

toTransport :: Atom atom => Set a -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error (Set a) Source #

toTransportList :: Atom atom => [Set a] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [Set a] Source #

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

Defined in Data.Autolib.Transport

Methods

toTransport :: Atom atom => Maybe a -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error (Maybe a) Source #

toTransportList :: Atom atom => [Maybe a] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [Maybe a] Source #

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

Defined in Data.Autolib.Transport

Methods

toTransport :: Atom atom => [a] -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error [a] Source #

toTransportList :: Atom atom => [[a]] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [[a]] Source #

(Ord a, ToTransport a, ToTransport b) => ToTransport (Map a b) Source # 
Instance details

Defined in Data.Autolib.Transport

Methods

toTransport :: Atom atom => Map a b -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error (Map a b) Source #

toTransportList :: Atom atom => [Map a b] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [Map a b] Source #

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

Defined in Data.Autolib.Transport

Methods

toTransport :: Atom atom => Either a b -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error (Either a b) Source #

toTransportList :: Atom atom => [Either a b] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [Either a b] Source #

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

Defined in Data.Autolib.Transport

Methods

toTransport :: Atom atom => (a, b) -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error (a, b) Source #

toTransportList :: Atom atom => [(a, b)] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [(a, b)] Source #

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

Defined in Data.Autolib.Transport

Methods

toTransport :: Atom atom => (a, b, c) -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error (a, b, c) Source #

toTransportList :: Atom atom => [(a, b, c)] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [(a, b, c)] Source #

data Trans atom Source #

Intermediate data representation. It can contain atoms (Bool, Double, Integer, String, ByteString), arrays (lists) and objects (maps with string keys).

Constructors

TrAtom atom 
TrArray [Trans atom] 
TrObject [(String, Trans atom)] 

class Atom atom => Transport base atom | base -> atom where Source #

Final conversion to transport layer.

Methods

encode :: Trans atom -> base Source #

decode :: base -> Error (Trans atom) Source #

Instances

Instances details
Transport Value Value Source # 
Instance details

Defined in Data.Autolib.Transport.HaXR

Transport JSValue JSValue Source # 
Instance details

Defined in Data.Autolib.Transport.JSON

class ConvertAtom a b where Source #

The ConvertAtom class is responsible for converting between atoms and their underlying representation.

Methods

fromAtom :: a -> Error b Source #

toAtom :: b -> a Source #

Instances

Instances details
ConvertAtom Value ByteString Source # 
Instance details

Defined in Data.Autolib.Transport.HaXR

ConvertAtom Value Text Source # 
Instance details

Defined in Data.Autolib.Transport.HaXR

ConvertAtom Value Integer Source # 
Instance details

Defined in Data.Autolib.Transport.HaXR

ConvertAtom Value String Source # 
Instance details

Defined in Data.Autolib.Transport.HaXR

ConvertAtom Value Bool Source # 
Instance details

Defined in Data.Autolib.Transport.HaXR

ConvertAtom Value Double Source # 
Instance details

Defined in Data.Autolib.Transport.HaXR

ConvertAtom JSValue ByteString Source # 
Instance details

Defined in Data.Autolib.Transport.JSON

ConvertAtom JSValue Text Source # 
Instance details

Defined in Data.Autolib.Transport.JSON

ConvertAtom JSValue Integer Source # 
Instance details

Defined in Data.Autolib.Transport.JSON

ConvertAtom JSValue String Source # 
Instance details

Defined in Data.Autolib.Transport.JSON

ConvertAtom JSValue Bool Source # 
Instance details

Defined in Data.Autolib.Transport.JSON

ConvertAtom JSValue Double Source # 
Instance details

Defined in Data.Autolib.Transport.JSON

data Error a Source #

'Error a' is isomorphic to Either String a but could be extended to encode more error conditions.

Constructors

Error String 
Result a 

Instances

Instances details
Alternative Error Source # 
Instance details

Defined in Data.Autolib.Transport.Error

Methods

empty :: Error a #

(<|>) :: Error a -> Error a -> Error a #

some :: Error a -> Error [a] #

many :: Error a -> Error [a] #

Applicative Error Source # 
Instance details

Defined in Data.Autolib.Transport.Error

Methods

pure :: a -> Error a #

(<*>) :: Error (a -> b) -> Error a -> Error b #

liftA2 :: (a -> b -> c) -> Error a -> Error b -> Error c #

(*>) :: Error a -> Error b -> Error b #

(<*) :: Error a -> Error b -> Error a #

Functor Error Source # 
Instance details

Defined in Data.Autolib.Transport.Error

Methods

fmap :: (a -> b) -> Error a -> Error b #

(<$) :: a -> Error b -> Error a #

Monad Error Source # 
Instance details

Defined in Data.Autolib.Transport.Error

Methods

(>>=) :: Error a -> (a -> Error b) -> Error b #

(>>) :: Error a -> Error b -> Error b #

return :: a -> Error a #

MonadFail Error Source # 
Instance details

Defined in Data.Autolib.Transport.Error

Methods

fail :: String -> Error a #

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

Defined in Data.Autolib.Transport.Error

Methods

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

show :: Error a -> String #

showList :: [Error a] -> ShowS #

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

Defined in Data.Autolib.Transport.Error

Methods

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

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

Orphan instances

ToTransport ByteString Source # 
Instance details

ToTransport Text Source # 
Instance details

Methods

toTransport :: Atom atom => Text -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error Text Source #

toTransportList :: Atom atom => [Text] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [Text] Source #

ToTransport Integer Source # 
Instance details

Methods

toTransport :: Atom atom => Integer -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error Integer Source #

toTransportList :: Atom atom => [Integer] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [Integer] Source #

ToTransport () Source # 
Instance details

Methods

toTransport :: Atom atom => () -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error () Source #

toTransportList :: Atom atom => [()] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [()] Source #

ToTransport Bool Source # 
Instance details

Methods

toTransport :: Atom atom => Bool -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error Bool Source #

toTransportList :: Atom atom => [Bool] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [Bool] Source #

ToTransport Char Source # 
Instance details

Methods

toTransport :: Atom atom => Char -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error Char Source #

toTransportList :: Atom atom => [Char] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [Char] Source #

ToTransport Double Source # 
Instance details

Methods

toTransport :: Atom atom => Double -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error Double Source #

toTransportList :: Atom atom => [Double] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [Double] Source #

ToTransport Int Source # 
Instance details

Methods

toTransport :: Atom atom => Int -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error Int Source #

toTransportList :: Atom atom => [Int] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [Int] Source #

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

Methods

toTransport :: Atom atom => Set a -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error (Set a) Source #

toTransportList :: Atom atom => [Set a] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [Set a] Source #

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

Methods

toTransport :: Atom atom => Maybe a -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error (Maybe a) Source #

toTransportList :: Atom atom => [Maybe a] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [Maybe a] Source #

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

Methods

toTransport :: Atom atom => [a] -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error [a] Source #

toTransportList :: Atom atom => [[a]] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [[a]] Source #

(Ord a, ToTransport a, ToTransport b) => ToTransport (Map a b) Source # 
Instance details

Methods

toTransport :: Atom atom => Map a b -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error (Map a b) Source #

toTransportList :: Atom atom => [Map a b] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [Map a b] Source #

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

Methods

toTransport :: Atom atom => Either a b -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error (Either a b) Source #

toTransportList :: Atom atom => [Either a b] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [Either a b] Source #

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

Methods

toTransport :: Atom atom => (a, b) -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error (a, b) Source #

toTransportList :: Atom atom => [(a, b)] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [(a, b)] Source #

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

Methods

toTransport :: Atom atom => (a, b, c) -> Trans atom Source #

fromTransport :: Atom atom => Trans atom -> Error (a, b, c) Source #

toTransportList :: Atom atom => [(a, b, c)] -> Trans atom Source #

fromTransportList :: Atom atom => Trans atom -> Error [(a, b, c)] Source #