{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE IncoherentInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}

-- Copyright (C) 2009-2012 John Millikin <john@john-millikin.com>
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.

module DBus.Internal.Types where

import           Control.DeepSeq
import           Control.Monad (liftM, when, (>=>))
import           Control.Monad.Catch
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BS8
import qualified Data.ByteString.Lazy as BL
import           Data.Char (ord)
import           Data.Coerce
import           Data.Int
import           Data.List (intercalate)
import           Data.List.Split (splitOn)
import qualified Data.Map
import           Data.Map (Map)
import qualified Data.String
import qualified Data.Text
import           Data.Text (Text)
import qualified Data.Text.Lazy
import           Data.Typeable (Typeable, Proxy(..))
import qualified Data.Vector
import           Data.Vector (Vector)
import           Data.Word
import           GHC.Generics
import qualified Language.Haskell.TH.Lift as THL
import           System.Posix.Types (Fd)
import           Text.ParserCombinators.Parsec ((<|>), oneOf)
import qualified Text.ParserCombinators.Parsec as Parsec

data Type
    = TypeBoolean
    | TypeWord8
    | TypeWord16
    | TypeWord32
    | TypeWord64
    | TypeInt16
    | TypeInt32
    | TypeInt64
    | TypeDouble
    | TypeUnixFd
    | TypeString
    | TypeSignature
    | TypeObjectPath
    | TypeVariant
    | TypeArray Type
    | TypeDictionary Type Type
    | TypeStructure [Type]
    deriving (Type -> Type -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Type -> Type -> Bool
$c/= :: Type -> Type -> Bool
== :: Type -> Type -> Bool
$c== :: Type -> Type -> Bool
Eq, Eq Type
Type -> Type -> Bool
Type -> Type -> Ordering
Type -> Type -> Type
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Type -> Type -> Type
$cmin :: Type -> Type -> Type
max :: Type -> Type -> Type
$cmax :: Type -> Type -> Type
>= :: Type -> Type -> Bool
$c>= :: Type -> Type -> Bool
> :: Type -> Type -> Bool
$c> :: Type -> Type -> Bool
<= :: Type -> Type -> Bool
$c<= :: Type -> Type -> Bool
< :: Type -> Type -> Bool
$c< :: Type -> Type -> Bool
compare :: Type -> Type -> Ordering
$ccompare :: Type -> Type -> Ordering
Ord, forall x. Rep Type x -> Type
forall x. Type -> Rep Type x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Type x -> Type
$cfrom :: forall x. Type -> Rep Type x
Generic)

instance NFData Type

instance Show Type where
    showsPrec :: Int -> Type -> ShowS
showsPrec Int
d = String -> ShowS
showString forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Type -> String
showType (Int
d forall a. Ord a => a -> a -> Bool
> Int
10)

showType :: Bool -> Type -> String
showType :: Bool -> Type -> String
showType Bool
paren Type
t = case Type
t of
    Type
TypeBoolean -> String
"Bool"
    Type
TypeWord8 -> String
"Word8"
    Type
TypeWord16 -> String
"Word16"
    Type
TypeWord32 -> String
"Word32"
    Type
TypeWord64 -> String
"Word64"
    Type
TypeInt16 -> String
"Int16"
    Type
TypeInt32 -> String
"Int32"
    Type
TypeInt64 -> String
"Int64"
    Type
TypeDouble -> String
"Double"
    Type
TypeUnixFd -> String
"UnixFd"
    Type
TypeString -> String
"String"
    Type
TypeSignature -> String
"Signature"
    Type
TypeObjectPath -> String
"ObjectPath"
    Type
TypeVariant -> String
"Variant"
    TypeArray Type
t' -> forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [String
"[", forall a. Show a => a -> String
show Type
t', String
"]"]
    TypeDictionary Type
kt Type
vt -> Bool -> ShowS -> ShowS
showParen Bool
paren (
                            String -> ShowS
showString String
"Dict " forall b c a. (b -> c) -> (a -> b) -> a -> c
.
                            forall a. Show a => a -> ShowS
shows Type
kt forall b c a. (b -> c) -> (a -> b) -> a -> c
.
                            String -> ShowS
showString String
" " forall b c a. (b -> c) -> (a -> b) -> a -> c
.
                            forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 Type
vt) String
""
    TypeStructure [Type]
ts -> forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
        [String
"(", forall a. [a] -> [[a]] -> [a]
intercalate String
", " (forall a b. (a -> b) -> [a] -> [b]
map forall a. Show a => a -> String
show [Type]
ts), String
")"]

-- | A signature is a list of D-Bus types, obeying some basic rules of
-- validity.
--
-- The rules of signature validity are complex: see
-- <http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-signatures>
-- for details.
newtype Signature = Signature [Type]
    deriving (Signature -> Signature -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Signature -> Signature -> Bool
$c/= :: Signature -> Signature -> Bool
== :: Signature -> Signature -> Bool
$c== :: Signature -> Signature -> Bool
Eq, Eq Signature
Signature -> Signature -> Bool
Signature -> Signature -> Ordering
Signature -> Signature -> Signature
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Signature -> Signature -> Signature
$cmin :: Signature -> Signature -> Signature
max :: Signature -> Signature -> Signature
$cmax :: Signature -> Signature -> Signature
>= :: Signature -> Signature -> Bool
$c>= :: Signature -> Signature -> Bool
> :: Signature -> Signature -> Bool
$c> :: Signature -> Signature -> Bool
<= :: Signature -> Signature -> Bool
$c<= :: Signature -> Signature -> Bool
< :: Signature -> Signature -> Bool
$c< :: Signature -> Signature -> Bool
compare :: Signature -> Signature -> Ordering
$ccompare :: Signature -> Signature -> Ordering
Ord, Signature -> ()
forall a. (a -> ()) -> NFData a
rnf :: Signature -> ()
$crnf :: Signature -> ()
NFData)

-- | Get the list of types in a signature. The inverse of 'signature'.
signatureTypes :: Signature -> [Type]
signatureTypes :: Signature -> [Type]
signatureTypes (Signature [Type]
types) = [Type]
types

instance Show Signature where
    showsPrec :: Int -> Signature -> ShowS
showsPrec Int
d Signature
sig = Bool -> ShowS -> ShowS
showParen (Int
d forall a. Ord a => a -> a -> Bool
> Int
10) forall a b. (a -> b) -> a -> b
$
        String -> ShowS
showString String
"Signature " forall b c a. (b -> c) -> (a -> b) -> a -> c
.
        forall a. Show a => a -> ShowS
shows (Signature -> String
formatSignature Signature
sig)

-- | Convert a signature into a signature string. The inverse of
-- 'parseSignature'.
formatSignature :: Signature -> String
formatSignature :: Signature -> String
formatSignature = forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Type -> String
typeCode forall b c a. (b -> c) -> (a -> b) -> a -> c
. Signature -> [Type]
signatureTypes

typeCode :: Type -> String
typeCode :: Type -> String
typeCode Type
TypeBoolean    = String
"b"
typeCode Type
TypeWord8      = String
"y"
typeCode Type
TypeWord16     = String
"q"
typeCode Type
TypeWord32     = String
"u"
typeCode Type
TypeWord64     = String
"t"
typeCode Type
TypeInt16      = String
"n"
typeCode Type
TypeInt32      = String
"i"
typeCode Type
TypeInt64      = String
"x"
typeCode Type
TypeDouble     = String
"d"
typeCode Type
TypeUnixFd     = String
"h"
typeCode Type
TypeString     = String
"s"
typeCode Type
TypeSignature  = String
"g"
typeCode Type
TypeObjectPath = String
"o"
typeCode Type
TypeVariant    = String
"v"
typeCode (TypeArray Type
t)  = Char
'a' forall a. a -> [a] -> [a]
: Type -> String
typeCode Type
t
typeCode (TypeDictionary Type
kt Type
vt) = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
    [ String
"a{", Type -> String
typeCode Type
kt , Type -> String
typeCode Type
vt, String
"}"]

typeCode (TypeStructure [Type]
ts) = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
    [String
"(", forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Type -> String
typeCode [Type]
ts, String
")"]

instance Data.String.IsString Signature where
    fromString :: String -> Signature
fromString = forall a. String -> (String -> Maybe a) -> String -> a
forceParse String
"signature" forall (m :: * -> *). MonadThrow m => String -> m Signature
parseSignature

-- | Convert a list of types into a valid signature.
--
-- Throws if the given types are not a valid signature.
signature :: MonadThrow m => [Type] -> m Signature
signature :: forall (m :: * -> *). MonadThrow m => [Type] -> m Signature
signature = forall (m :: * -> *). MonadThrow m => [Type] -> m Signature
check where
    check :: [Type] -> m Signature
check [Type]
ts = if [Type] -> Int
sumLen [Type]
ts forall a. Ord a => a -> a -> Bool
> Int
255
        then forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM forall a b. (a -> b) -> a -> b
$ String -> IOError
userError String
"invalid signature"
        else forall (f :: * -> *) a. Applicative f => a -> f a
pure ([Type] -> Signature
Signature [Type]
ts)
    sumLen :: [Type] -> Int
    sumLen :: [Type] -> Int
sumLen = forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map Type -> Int
len

    len :: Type -> Int
len (TypeArray Type
t) = Int
1 forall a. Num a => a -> a -> a
+ Type -> Int
len Type
t
    len (TypeDictionary Type
kt Type
vt)
        | Type -> Bool
typeIsAtomic Type
kt = Int
3 forall a. Num a => a -> a -> a
+ Type -> Int
len Type
kt forall a. Num a => a -> a -> a
+ Type -> Int
len Type
vt
        | Bool
otherwise = Int
256
    len (TypeStructure []) = Int
256
    len (TypeStructure [Type]
ts) = Int
2 forall a. Num a => a -> a -> a
+ [Type] -> Int
sumLen [Type]
ts
    len Type
_ = Int
1

    typeIsAtomic :: Type -> Bool
typeIsAtomic Type
TypeVariant = Bool
False
    typeIsAtomic TypeArray{} = Bool
False
    typeIsAtomic TypeDictionary{} = Bool
False
    typeIsAtomic TypeStructure{} = Bool
False
    typeIsAtomic Type
_ = Bool
True

-- | Convert a list of types into a valid signature.
--
-- Throws an exception if the given types are not a valid signature.
signature_ :: [Type] -> Signature
signature_ :: [Type] -> Signature
signature_ [Type]
ts = case forall (m :: * -> *). MonadThrow m => [Type] -> m Signature
signature [Type]
ts of
    Just Signature
sig -> Signature
sig
    Maybe Signature
Nothing -> forall a. HasCallStack => String -> a
error (String
"invalid signature: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show [Type]
ts)

-- | Parse a signature string into a valid signature.
--
-- Throws if the given string is not a valid signature.
parseSignature :: MonadThrow m => String -> m Signature
parseSignature :: forall (m :: * -> *). MonadThrow m => String -> m Signature
parseSignature String
s = do
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (forall (t :: * -> *) a. Foldable t => t a -> Int
length String
s forall a. Ord a => a -> a -> Bool
> Int
255) forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM forall a b. (a -> b) -> a -> b
$ String -> IOError
userError String
"string too long"
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (\Char
c -> Char -> Int
ord Char
c forall a. Ord a => a -> a -> Bool
> Int
0x7F) String
s) forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM forall a b. (a -> b) -> a -> b
$ String -> IOError
userError String
"invalid signature"
    forall (m :: * -> *). MonadThrow m => ByteString -> m Signature
parseSignatureBytes (String -> ByteString
BS8.pack String
s)

parseSignatureBytes :: MonadThrow m => BS.ByteString -> m Signature
parseSignatureBytes :: forall (m :: * -> *). MonadThrow m => ByteString -> m Signature
parseSignatureBytes ByteString
bytes =
    case ByteString -> Int
BS.length ByteString
bytes of
        Int
0 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure ([Type] -> Signature
Signature [])
        Int
1 -> forall (m :: * -> *). MonadThrow m => ByteString -> m Signature
parseSigFast ByteString
bytes
        Int
len | Int
len forall a. Ord a => a -> a -> Bool
<= Int
255 -> forall (m :: * -> *). MonadThrow m => ByteString -> m Signature
parseSigFull ByteString
bytes
        Int
_ -> forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM forall a b. (a -> b) -> a -> b
$ String -> IOError
userError String
"string too long"

parseSigFast :: MonadThrow m => BS.ByteString -> m Signature
parseSigFast :: forall (m :: * -> *). MonadThrow m => ByteString -> m Signature
parseSigFast ByteString
bytes =
    let byte :: Word8
byte = HasCallStack => ByteString -> Word8
BS.head ByteString
bytes
     in forall a. Int -> (Type -> a) -> a -> a
parseAtom (forall a b. (Integral a, Num b) => a -> b
fromIntegral Word8
byte)
            (\Type
t -> forall (f :: * -> *) a. Applicative f => a -> f a
pure ([Type] -> Signature
Signature [Type
t]))
            (case Word8
byte of
                Word8
0x76 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure ([Type] -> Signature
Signature [Type
TypeVariant])
                Word8
_ -> forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM forall a b. (a -> b) -> a -> b
$ String -> IOError
userError String
"invalid signature")

parseAtom :: Int -> (Type -> a) -> a -> a
parseAtom :: forall a. Int -> (Type -> a) -> a -> a
parseAtom Int
byte Type -> a
yes a
no = case Int
byte of
    Int
0x62 -> Type -> a
yes Type
TypeBoolean
    Int
0x6E -> Type -> a
yes Type
TypeInt16
    Int
0x69 -> Type -> a
yes Type
TypeInt32
    Int
0x78 -> Type -> a
yes Type
TypeInt64
    Int
0x79 -> Type -> a
yes Type
TypeWord8
    Int
0x71 -> Type -> a
yes Type
TypeWord16
    Int
0x75 -> Type -> a
yes Type
TypeWord32
    Int
0x74 -> Type -> a
yes Type
TypeWord64
    Int
0x64 -> Type -> a
yes Type
TypeDouble
    Int
0x68 -> Type -> a
yes Type
TypeUnixFd
    Int
0x73 -> Type -> a
yes Type
TypeString
    Int
0x67 -> Type -> a
yes Type
TypeSignature
    Int
0x6F -> Type -> a
yes Type
TypeObjectPath
    Int
_ -> a
no
{-# INLINE parseAtom #-}

data SigParseError = SigParseError
    deriving (Int -> SigParseError -> ShowS
[SigParseError] -> ShowS
SigParseError -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SigParseError] -> ShowS
$cshowList :: [SigParseError] -> ShowS
show :: SigParseError -> String
$cshow :: SigParseError -> String
showsPrec :: Int -> SigParseError -> ShowS
$cshowsPrec :: Int -> SigParseError -> ShowS
Show, Typeable)

instance Exception SigParseError

peekWord8AsInt :: BS.ByteString -> Int -> Int
peekWord8AsInt :: ByteString -> Int -> Int
peekWord8AsInt ByteString
str Int
i = forall a b. (Integral a, Num b) => a -> b
fromIntegral forall a b. (a -> b) -> a -> b
$ HasCallStack => ByteString -> Int -> Word8
BS.index ByteString
str Int
i

parseSigFull :: MonadThrow m => BS.ByteString -> m Signature
parseSigFull :: forall (m :: * -> *). MonadThrow m => ByteString -> m Signature
parseSigFull ByteString
bytes = [Type] -> Signature
Signature forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Type] -> Int -> m [Type]
mainLoop [] Int
0
  where
    len :: Int
len = ByteString -> Int
BS.length ByteString
bytes
    mainLoop :: [Type] -> Int -> m [Type]
mainLoop [Type]
acc Int
ii | Int
ii forall a. Ord a => a -> a -> Bool
>= Int
len = forall (f :: * -> *) a. Applicative f => a -> f a
pure (forall a. [a] -> [a]
reverse [Type]
acc)
    mainLoop [Type]
acc Int
ii = do
        let c :: Int
c = ByteString -> Int -> Int
peekWord8AsInt ByteString
bytes Int
ii
        let next :: Type -> m [Type]
next Type
t = [Type] -> Int -> m [Type]
mainLoop (Type
t forall a. a -> [a] -> [a]
: [Type]
acc) (Int
ii forall a. Num a => a -> a -> a
+ Int
1)
        forall a. Int -> (Type -> a) -> a -> a
parseAtom Int
c Type -> m [Type]
next forall a b. (a -> b) -> a -> b
$ case Int
c of
            Int
0x76 -> Type -> m [Type]
next Type
TypeVariant
            Int
0x28 -> do -- '('
                (Int
ii', Type
t) <- Int -> m (Int, Type)
structure (Int
ii forall a. Num a => a -> a -> a
+ Int
1)
                [Type] -> Int -> m [Type]
mainLoop (Type
t forall a. a -> [a] -> [a]
: [Type]
acc) Int
ii'
            Int
0x61 -> do -- 'a'
                (Int
ii', Type
t) <- Int -> m (Int, Type)
array (Int
ii forall a. Num a => a -> a -> a
+ Int
1)
                [Type] -> Int -> m [Type]
mainLoop (Type
t forall a. a -> [a] -> [a]
: [Type]
acc) Int
ii'
            Int
_ -> forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM SigParseError
SigParseError

    structure :: Int -> m (Int, Type)
structure = [Type] -> Int -> m (Int, Type)
loop [] where
        loop :: [Type] -> Int -> m (Int, Type)
loop [Type]
_ Int
ii | Int
ii forall a. Ord a => a -> a -> Bool
>= Int
len = forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM SigParseError
SigParseError
        loop [Type]
acc Int
ii = do
            let c :: Int
c = ByteString -> Int -> Int
peekWord8AsInt ByteString
bytes Int
ii
            let next :: Type -> m (Int, Type)
next Type
t = [Type] -> Int -> m (Int, Type)
loop (Type
t forall a. a -> [a] -> [a]
: [Type]
acc) (Int
ii forall a. Num a => a -> a -> a
+ Int
1)
            forall a. Int -> (Type -> a) -> a -> a
parseAtom Int
c Type -> m (Int, Type)
next forall a b. (a -> b) -> a -> b
$ case Int
c of
                Int
0x76 -> Type -> m (Int, Type)
next Type
TypeVariant
                Int
0x28 -> do -- '('
                    (Int
ii', Type
t) <- Int -> m (Int, Type)
structure (Int
ii forall a. Num a => a -> a -> a
+ Int
1)
                    [Type] -> Int -> m (Int, Type)
loop (Type
t forall a. a -> [a] -> [a]
: [Type]
acc) Int
ii'
                Int
0x61 -> do -- 'a'
                    (Int
ii', Type
t) <- Int -> m (Int, Type)
array (Int
ii forall a. Num a => a -> a -> a
+ Int
1)
                    [Type] -> Int -> m (Int, Type)
loop (Type
t forall a. a -> [a] -> [a]
: [Type]
acc) Int
ii'
                -- ')'
                Int
0x29 -> case [Type]
acc of
                    [] -> forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM SigParseError
SigParseError
                    [Type]
_ -> forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
ii forall a. Num a => a -> a -> a
+ Int
1, [Type] -> Type
TypeStructure (forall a. [a] -> [a]
reverse [Type]
acc))
                Int
_ -> forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM SigParseError
SigParseError

    array :: Int -> m (Int, Type)
array Int
ii | Int
ii forall a. Ord a => a -> a -> Bool
>= Int
len = forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM SigParseError
SigParseError
    array Int
ii = do
        let c :: Int
c = ByteString -> Int -> Int
peekWord8AsInt ByteString
bytes Int
ii
        let next :: Type -> f (Int, Type)
next Type
t = forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
ii forall a. Num a => a -> a -> a
+ Int
1, Type -> Type
TypeArray Type
t)
        forall a. Int -> (Type -> a) -> a -> a
parseAtom Int
c forall {f :: * -> *}. Applicative f => Type -> f (Int, Type)
next forall a b. (a -> b) -> a -> b
$ case Int
c of
            Int
0x76 -> forall {f :: * -> *}. Applicative f => Type -> f (Int, Type)
next Type
TypeVariant
            Int
0x7B -> Int -> m (Int, Type)
dict (Int
ii forall a. Num a => a -> a -> a
+ Int
1) -- '{'
            Int
0x28 -> do -- '('
                (Int
ii', Type
t) <- Int -> m (Int, Type)
structure (Int
ii forall a. Num a => a -> a -> a
+ Int
1)
                forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
ii', Type -> Type
TypeArray Type
t)
            Int
0x61 -> do -- 'a'
                (Int
ii', Type
t) <- Int -> m (Int, Type)
array (Int
ii forall a. Num a => a -> a -> a
+ Int
1)
                forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
ii', Type -> Type
TypeArray Type
t)
            Int
_ -> forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM SigParseError
SigParseError

    dict :: Int -> m (Int, Type)
dict Int
ii | Int
ii forall a. Num a => a -> a -> a
+ Int
1 forall a. Ord a => a -> a -> Bool
>= Int
len = forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM SigParseError
SigParseError
    dict Int
ii = do
        let c1 :: Int
c1 = ByteString -> Int -> Int
peekWord8AsInt ByteString
bytes Int
ii
        let c2 :: Int
c2 = ByteString -> Int -> Int
peekWord8AsInt ByteString
bytes (Int
ii forall a. Num a => a -> a -> a
+ Int
1)

        let next :: b -> f (Int, b)
next b
t = forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
ii forall a. Num a => a -> a -> a
+ Int
2, b
t)
        (Int
ii', Type
t2) <- forall a. Int -> (Type -> a) -> a -> a
parseAtom Int
c2 forall {f :: * -> *} {b}. Applicative f => b -> f (Int, b)
next forall a b. (a -> b) -> a -> b
$ case Int
c2 of
            Int
0x76 -> forall {f :: * -> *} {b}. Applicative f => b -> f (Int, b)
next Type
TypeVariant
            Int
0x28 -> Int -> m (Int, Type)
structure (Int
ii forall a. Num a => a -> a -> a
+ Int
2) -- '('
            Int
0x61 -> Int -> m (Int, Type)
array (Int
ii forall a. Num a => a -> a -> a
+ Int
2) -- 'a'
            Int
_ -> forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM SigParseError
SigParseError

        if Int
ii' forall a. Ord a => a -> a -> Bool
>= Int
len
            then forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM SigParseError
SigParseError
            else do
                let c3 :: Int
c3 = ByteString -> Int -> Int
peekWord8AsInt ByteString
bytes Int
ii'
                if Int
c3 forall a. Eq a => a -> a -> Bool
== Int
0x7D
                    then do
                        Type
t1 <- forall a. Int -> (Type -> a) -> a -> a
parseAtom Int
c1 forall (f :: * -> *) a. Applicative f => a -> f a
pure (forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM SigParseError
SigParseError)
                        forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
ii' forall a. Num a => a -> a -> a
+ Int
1, Type -> Type -> Type
TypeDictionary Type
t1 Type
t2)
                    else forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM SigParseError
SigParseError

extractFromVariant :: IsValue a => Variant -> Maybe a
extractFromVariant :: forall a. IsValue a => Variant -> Maybe a
extractFromVariant (Variant (ValueVariant Variant
v)) = forall a. IsValue a => Variant -> Maybe a
extractFromVariant Variant
v
extractFromVariant Variant
v = forall a. IsVariant a => Variant -> Maybe a
fromVariant Variant
v

typeOf :: forall a. IsValue a => a -> Type
typeOf :: forall a. IsValue a => a -> Type
typeOf a
_ = forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a)

class IsVariant a where
    toVariant :: a -> Variant
    fromVariant :: Variant -> Maybe a

-- | Value types can be used as items in containers, such as lists or
-- dictionaries.
--
-- Users may not provide new instances of 'IsValue' because this could allow
-- containers to be created with items of heterogenous types.
class IsVariant a => IsValue a where
    typeOf_ :: Proxy a -> Type
    toValue :: a -> Value
    fromValue :: Value -> Maybe a

-- | Atomic types can be used as keys to dictionaries.
--
-- Users may not provide new instances of 'IsAtom' because this could allow
-- dictionaries to be created with invalid keys.
class IsValue a => IsAtom a where
    toAtom :: a -> Atom
    fromAtom :: Atom -> Maybe a

-- | Variants may contain any other built-in D-Bus value. Besides
-- representing native @VARIANT@ values, they allow type-safe storage and
-- inspection of D-Bus collections.
newtype Variant = Variant Value
    deriving (Variant -> Variant -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Variant -> Variant -> Bool
$c/= :: Variant -> Variant -> Bool
== :: Variant -> Variant -> Bool
$c== :: Variant -> Variant -> Bool
Eq)

data Value
    = ValueAtom Atom
    | ValueVariant Variant
    | ValueBytes BS.ByteString
    | ValueVector Type (Vector Value)
    | ValueMap Type Type (Map Atom Value)
    | ValueStructure [Value]
    deriving (Int -> Value -> ShowS
[Value] -> ShowS
Value -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Value] -> ShowS
$cshowList :: [Value] -> ShowS
show :: Value -> String
$cshow :: Value -> String
showsPrec :: Int -> Value -> ShowS
$cshowsPrec :: Int -> Value -> ShowS
Show)

data Atom
    = AtomBool Bool
    | AtomWord8 Word8
    | AtomWord16 Word16
    | AtomWord32 Word32
    | AtomWord64 Word64
    | AtomInt16 Int16
    | AtomInt32 Int32
    | AtomInt64 Int64
    | AtomDouble Double
    | AtomUnixFd Fd
    | AtomText Text
    | AtomSignature Signature
    | AtomObjectPath ObjectPath
    deriving (Int -> Atom -> ShowS
[Atom] -> ShowS
Atom -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Atom] -> ShowS
$cshowList :: [Atom] -> ShowS
show :: Atom -> String
$cshow :: Atom -> String
showsPrec :: Int -> Atom -> ShowS
$cshowsPrec :: Int -> Atom -> ShowS
Show, Atom -> Atom -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Atom -> Atom -> Bool
$c/= :: Atom -> Atom -> Bool
== :: Atom -> Atom -> Bool
$c== :: Atom -> Atom -> Bool
Eq, Eq Atom
Atom -> Atom -> Bool
Atom -> Atom -> Ordering
Atom -> Atom -> Atom
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Atom -> Atom -> Atom
$cmin :: Atom -> Atom -> Atom
max :: Atom -> Atom -> Atom
$cmax :: Atom -> Atom -> Atom
>= :: Atom -> Atom -> Bool
$c>= :: Atom -> Atom -> Bool
> :: Atom -> Atom -> Bool
$c> :: Atom -> Atom -> Bool
<= :: Atom -> Atom -> Bool
$c<= :: Atom -> Atom -> Bool
< :: Atom -> Atom -> Bool
$c< :: Atom -> Atom -> Bool
compare :: Atom -> Atom -> Ordering
$ccompare :: Atom -> Atom -> Ordering
Ord)

instance Eq Value where
    == :: Value -> Value -> Bool
(==) (ValueBytes ByteString
x) Value
y = case Value
y of
        ValueBytes ByteString
y' -> ByteString
x forall a. Eq a => a -> a -> Bool
== ByteString
y'
        ValueVector Type
TypeWord8 Vector Value
y' -> ByteString
x forall a. Eq a => a -> a -> Bool
== Vector Value -> ByteString
vectorToBytes Vector Value
y'
        Value
_ -> Bool
False

    (==) (ValueVector Type
TypeWord8 Vector Value
x) Value
y = case Value
y of
        ValueBytes ByteString
y' -> Vector Value -> ByteString
vectorToBytes Vector Value
x forall a. Eq a => a -> a -> Bool
== ByteString
y'
        ValueVector Type
TypeWord8 Vector Value
y' -> Vector Value
x forall a. Eq a => a -> a -> Bool
== Vector Value
y'
        Value
_ -> Bool
False

    (==) (ValueAtom Atom
x) (ValueAtom Atom
y) = Atom
x forall a. Eq a => a -> a -> Bool
== Atom
y
    (==) (ValueVariant Variant
x) (ValueVariant Variant
y) = Variant
x forall a. Eq a => a -> a -> Bool
== Variant
y
    (==) (ValueVector Type
tx Vector Value
x) (ValueVector Type
ty Vector Value
y) = Type
tx forall a. Eq a => a -> a -> Bool
== Type
ty Bool -> Bool -> Bool
&& Vector Value
x forall a. Eq a => a -> a -> Bool
== Vector Value
y
    (==) (ValueMap Type
ktx Type
vtx Map Atom Value
x) (ValueMap Type
kty Type
vty Map Atom Value
y) = Type
ktx forall a. Eq a => a -> a -> Bool
== Type
kty Bool -> Bool -> Bool
&& Type
vtx forall a. Eq a => a -> a -> Bool
== Type
vty Bool -> Bool -> Bool
&& Map Atom Value
x forall a. Eq a => a -> a -> Bool
== Map Atom Value
y
    (==) (ValueStructure [Value]
x) (ValueStructure [Value]
y) = [Value]
x forall a. Eq a => a -> a -> Bool
== [Value]
y
    (==) Value
_ Value
_ = Bool
False

showAtom :: Bool -> Atom -> String
showAtom :: Bool -> Atom -> String
showAtom Bool
_ (AtomBool Bool
x) = forall a. Show a => a -> String
show Bool
x
showAtom Bool
_ (AtomWord8 Word8
x) = forall a. Show a => a -> String
show Word8
x
showAtom Bool
_ (AtomWord16 Word16
x) = forall a. Show a => a -> String
show Word16
x
showAtom Bool
_ (AtomWord32 Word32
x) = forall a. Show a => a -> String
show Word32
x
showAtom Bool
_ (AtomWord64 Word64
x) = forall a. Show a => a -> String
show Word64
x
showAtom Bool
_ (AtomInt16 Int16
x) = forall a. Show a => a -> String
show Int16
x
showAtom Bool
_ (AtomInt32 Int32
x) = forall a. Show a => a -> String
show Int32
x
showAtom Bool
_ (AtomInt64 Int64
x) = forall a. Show a => a -> String
show Int64
x
showAtom Bool
_ (AtomDouble Double
x) = forall a. Show a => a -> String
show Double
x
showAtom Bool
p (AtomUnixFd Fd
x) = Bool -> ShowS -> ShowS
showParen Bool
p (String -> ShowS
showString String
"UnixFd " forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> ShowS
shows Fd
x) String
""
showAtom Bool
_ (AtomText Text
x) = forall a. Show a => a -> String
show Text
x
showAtom Bool
p (AtomSignature Signature
x) = forall a. Show a => Int -> a -> ShowS
showsPrec (if Bool
p then Int
11 else Int
0) Signature
x String
""
showAtom Bool
p (AtomObjectPath ObjectPath
x) = forall a. Show a => Int -> a -> ShowS
showsPrec (if Bool
p then Int
11 else Int
0) ObjectPath
x String
""

showValue :: Bool -> Value -> String
showValue :: Bool -> Value -> String
showValue Bool
p (ValueAtom Atom
x) = Bool -> Atom -> String
showAtom Bool
p Atom
x
showValue Bool
p (ValueVariant Variant
x) = forall a. Show a => Int -> a -> ShowS
showsPrec (if Bool
p then Int
11 else Int
0) Variant
x String
""
showValue Bool
_ (ValueBytes ByteString
xs) = Char
'b' forall a. a -> [a] -> [a]
: forall a. Show a => a -> String
show ByteString
xs
showValue Bool
_ (ValueVector Type
TypeWord8 Vector Value
xs) = Char
'b' forall a. a -> [a] -> [a]
: forall a. Show a => a -> String
show (Vector Value -> ByteString
vectorToBytes Vector Value
xs)
showValue Bool
_ (ValueVector Type
_ Vector Value
xs) = forall a. String -> (a -> String) -> String -> [a] -> String
showThings String
"[" (Bool -> Value -> String
showValue Bool
False) String
"]" (forall a. Vector a -> [a]
Data.Vector.toList Vector Value
xs)
showValue Bool
_ (ValueMap Type
_ Type
_ Map Atom Value
xs) = forall a. String -> (a -> String) -> String -> [a] -> String
showThings String
"{" (Atom, Value) -> String
showPair String
"}" (forall k a. Map k a -> [(k, a)]
Data.Map.toList Map Atom Value
xs) where
    showPair :: (Atom, Value) -> String
showPair (Atom
k, Value
v) = Bool -> Atom -> String
showAtom Bool
False Atom
k forall a. [a] -> [a] -> [a]
++ String
": " forall a. [a] -> [a] -> [a]
++ Bool -> Value -> String
showValue Bool
False Value
v
showValue Bool
_ (ValueStructure [Value]
xs) = forall a. String -> (a -> String) -> String -> [a] -> String
showThings String
"(" (Bool -> Value -> String
showValue Bool
False) String
")" [Value]
xs

showThings :: String -> (a -> String) -> String -> [a] -> String
showThings :: forall a. String -> (a -> String) -> String -> [a] -> String
showThings String
a a -> String
s String
z [a]
xs = String
a forall a. [a] -> [a] -> [a]
++ forall a. [a] -> [[a]] -> [a]
intercalate String
", " (forall a b. (a -> b) -> [a] -> [b]
map a -> String
s [a]
xs) forall a. [a] -> [a] -> [a]
++ String
z

vectorToBytes :: Vector Value -> BS.ByteString
vectorToBytes :: Vector Value -> ByteString
vectorToBytes = [Word8] -> ByteString
BS.pack
              forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Vector a -> [a]
Data.Vector.toList
              forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> Vector a -> Vector b
Data.Vector.map (\(ValueAtom (AtomWord8 Word8
x)) -> Word8
x)

instance Show Variant where
    showsPrec :: Int -> Variant -> ShowS
showsPrec Int
d (Variant Value
x) = Bool -> ShowS -> ShowS
showParen (Int
d forall a. Ord a => a -> a -> Bool
> Int
10) forall a b. (a -> b) -> a -> b
$
        String -> ShowS
showString String
"Variant " forall b c a. (b -> c) -> (a -> b) -> a -> c
.  String -> ShowS
showString (Bool -> Value -> String
showValue Bool
True Value
x)

-- | Every variant is strongly-typed; that is, the type of its contained
-- value is known at all times. This function retrieves that type, so that
-- the correct cast can be used to retrieve the value.
variantType :: Variant -> Type
variantType :: Variant -> Type
variantType (Variant Value
val) = Value -> Type
valueType Value
val

valueType :: Value -> Type
valueType :: Value -> Type
valueType (ValueAtom Atom
x) = Atom -> Type
atomType Atom
x
valueType (ValueVariant Variant
_) = Type
TypeVariant
valueType (ValueVector Type
t Vector Value
_) = Type -> Type
TypeArray Type
t
valueType (ValueBytes ByteString
_) = Type -> Type
TypeArray Type
TypeWord8
valueType (ValueMap Type
kt Type
vt Map Atom Value
_) = Type -> Type -> Type
TypeDictionary Type
kt Type
vt
valueType (ValueStructure [Value]
vs) = [Type] -> Type
TypeStructure (forall a b. (a -> b) -> [a] -> [b]
map Value -> Type
valueType [Value]
vs)

atomType :: Atom -> Type
atomType :: Atom -> Type
atomType (AtomBool Bool
_) = Type
TypeBoolean
atomType (AtomWord8 Word8
_) = Type
TypeWord8
atomType (AtomWord16 Word16
_) = Type
TypeWord16
atomType (AtomWord32 Word32
_) = Type
TypeWord32
atomType (AtomWord64 Word64
_) = Type
TypeWord64
atomType (AtomInt16 Int16
_) = Type
TypeInt16
atomType (AtomInt32 Int32
_) = Type
TypeInt32
atomType (AtomInt64 Int64
_) = Type
TypeInt64
atomType (AtomDouble Double
_) = Type
TypeDouble
atomType (AtomUnixFd Fd
_) = Type
TypeUnixFd
atomType (AtomText Text
_) = Type
TypeString
atomType (AtomSignature Signature
_) = Type
TypeSignature
atomType (AtomObjectPath ObjectPath
_) = Type
TypeObjectPath

#define IS_ATOM(HsType, AtomCons, TypeCons) \
    instance IsAtom HsType where \
    { toAtom = AtomCons \
    ; fromAtom (AtomCons x) = Just x \
    ; fromAtom _ = Nothing \
    }; \
    instance IsValue HsType where \
    { typeOf_ _ = TypeCons \
    ; toValue = ValueAtom . toAtom \
    ; fromValue (ValueAtom x) = fromAtom x \
    ; fromValue _ = Nothing \
    }; \
    instance IsVariant HsType where \
    { toVariant = Variant . toValue \
    ; fromVariant (Variant val) = fromValue val \
    }

IS_ATOM(Bool,       AtomBool,       TypeBoolean)
IS_ATOM(Word8,      AtomWord8,      TypeWord8)
IS_ATOM(Word16,     AtomWord16,     TypeWord16)
IS_ATOM(Word32,     AtomWord32,     TypeWord32)
IS_ATOM(Word64,     AtomWord64,     TypeWord64)
IS_ATOM(Int16,      AtomInt16,      TypeInt16)
IS_ATOM(Int32,      AtomInt32,      TypeInt32)
IS_ATOM(Int64,      AtomInt64,      TypeInt64)
IS_ATOM(Double,     AtomDouble,     TypeDouble)
IS_ATOM(Fd,         AtomUnixFd,     TypeUnixFd)
IS_ATOM(Text,       AtomText,       TypeString)
IS_ATOM(Signature,  AtomSignature,  TypeSignature)
IS_ATOM(ObjectPath, AtomObjectPath, TypeObjectPath)

instance IsValue Variant where
    typeOf_ :: Proxy Variant -> Type
typeOf_ Proxy Variant
_ = Type
TypeVariant
    toValue :: Variant -> Value
toValue = Variant -> Value
ValueVariant
    fromValue :: Value -> Maybe Variant
fromValue (ValueVariant Variant
x) = forall a. a -> Maybe a
Just Variant
x
    fromValue Value
_ = forall a. Maybe a
Nothing

instance IsVariant Variant where
    toVariant :: Variant -> Variant
toVariant = Value -> Variant
Variant forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IsValue a => a -> Value
toValue
    fromVariant :: Variant -> Maybe Variant
fromVariant (Variant Value
val) = forall a. IsValue a => Value -> Maybe a
fromValue Value
val

instance IsAtom Data.Text.Lazy.Text where
    toAtom :: Text -> Atom
toAtom = forall a. IsAtom a => a -> Atom
toAtom forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
Data.Text.Lazy.toStrict
    fromAtom :: Atom -> Maybe Text
fromAtom = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> Text
Data.Text.Lazy.fromStrict forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IsAtom a => Atom -> Maybe a
fromAtom

instance IsValue Data.Text.Lazy.Text where
    typeOf_ :: Proxy Text -> Type
typeOf_ Proxy Text
_ = Type
TypeString
    toValue :: Text -> Value
toValue = Atom -> Value
ValueAtom forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IsAtom a => a -> Atom
toAtom
    fromValue :: Value -> Maybe Text
fromValue (ValueAtom Atom
x) = forall a. IsAtom a => Atom -> Maybe a
fromAtom Atom
x
    fromValue Value
_ = forall a. Maybe a
Nothing

instance IsVariant Data.Text.Lazy.Text where
    toVariant :: Text -> Variant
toVariant = Value -> Variant
Variant forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IsValue a => a -> Value
toValue
    fromVariant :: Variant -> Maybe Text
fromVariant (Variant Value
val) = forall a. IsValue a => Value -> Maybe a
fromValue Value
val

instance IsAtom String where
    toAtom :: String -> Atom
toAtom = forall a. IsAtom a => a -> Atom
toAtom forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
Data.Text.pack
    fromAtom :: Atom -> Maybe String
fromAtom = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> String
Data.Text.unpack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IsAtom a => Atom -> Maybe a
fromAtom

instance IsValue String where
    typeOf_ :: Proxy String -> Type
typeOf_ Proxy String
_ = Type
TypeString
    toValue :: String -> Value
toValue = Atom -> Value
ValueAtom forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IsAtom a => a -> Atom
toAtom
    fromValue :: Value -> Maybe String
fromValue (ValueAtom Atom
x) = forall a. IsAtom a => Atom -> Maybe a
fromAtom Atom
x
    fromValue Value
_ = forall a. Maybe a
Nothing

instance IsVariant String where
    toVariant :: String -> Variant
toVariant = Value -> Variant
Variant forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IsValue a => a -> Value
toValue
    fromVariant :: Variant -> Maybe String
fromVariant (Variant Value
val) = forall a. IsValue a => Value -> Maybe a
fromValue Value
val

instance IsValue a => IsValue (Vector a) where
    typeOf_ :: Proxy (Vector a) -> Type
typeOf_ Proxy (Vector a)
_ = Type -> Type
TypeArray (forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a))
    toValue :: Vector a -> Value
toValue Vector a
v = Type -> Vector Value -> Value
ValueVector
        (forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a))
        (forall a b. (a -> b) -> Vector a -> Vector b
Data.Vector.map forall a. IsValue a => a -> Value
toValue Vector a
v)
    fromValue :: Value -> Maybe (Vector a)
fromValue (ValueVector Type
_ Vector Value
v) = forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Vector a -> m (Vector b)
Data.Vector.mapM forall a. IsValue a => Value -> Maybe a
fromValue Vector Value
v
    fromValue Value
_ = forall a. Maybe a
Nothing

instance IsValue a => IsVariant (Vector a) where
    toVariant :: Vector a -> Variant
toVariant = Value -> Variant
Variant forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IsValue a => a -> Value
toValue
    fromVariant :: Variant -> Maybe (Vector a)
fromVariant (Variant Value
val) = forall a. IsValue a => Value -> Maybe a
fromValue Value
val

instance IsValue a => IsValue [a] where
    typeOf_ :: Proxy [a] -> Type
typeOf_ Proxy [a]
_ = Type -> Type
TypeArray (forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a))
    toValue :: [a] -> Value
toValue = forall a. IsValue a => a -> Value
toValue forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [a] -> Vector a
Data.Vector.fromList
    fromValue :: Value -> Maybe [a]
fromValue = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Vector a -> [a]
Data.Vector.toList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IsValue a => Value -> Maybe a
fromValue

instance IsValue a => IsVariant [a] where
    toVariant :: [a] -> Variant
toVariant = forall a. IsVariant a => a -> Variant
toVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [a] -> Vector a
Data.Vector.fromList
    fromVariant :: Variant -> Maybe [a]
fromVariant = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Vector a -> [a]
Data.Vector.toList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IsVariant a => Variant -> Maybe a
fromVariant

instance IsValue BS.ByteString where
    typeOf_ :: Proxy ByteString -> Type
typeOf_ Proxy ByteString
_ = Type -> Type
TypeArray Type
TypeWord8
    toValue :: ByteString -> Value
toValue = ByteString -> Value
ValueBytes
    fromValue :: Value -> Maybe ByteString
fromValue (ValueBytes ByteString
bs) = forall a. a -> Maybe a
Just ByteString
bs
    fromValue (ValueVector Type
TypeWord8 Vector Value
v) = forall a. a -> Maybe a
Just (Vector Value -> ByteString
vectorToBytes Vector Value
v)
    fromValue Value
_ = forall a. Maybe a
Nothing

instance IsVariant BS.ByteString where
    toVariant :: ByteString -> Variant
toVariant = Value -> Variant
Variant forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IsValue a => a -> Value
toValue
    fromVariant :: Variant -> Maybe ByteString
fromVariant (Variant Value
val) = forall a. IsValue a => Value -> Maybe a
fromValue Value
val

instance IsValue BL.ByteString where
    typeOf_ :: Proxy ByteString -> Type
typeOf_ Proxy ByteString
_ = Type -> Type
TypeArray Type
TypeWord8
    toValue :: ByteString -> Value
toValue = forall a. IsValue a => a -> Value
toValue
            forall b c a. (b -> c) -> (a -> b) -> a -> c
. [ByteString] -> ByteString
BS.concat
            forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [ByteString]
BL.toChunks
    fromValue :: Value -> Maybe ByteString
fromValue = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\ByteString
bs -> [ByteString] -> ByteString
BL.fromChunks [ByteString
bs])
              forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IsValue a => Value -> Maybe a
fromValue

instance IsVariant BL.ByteString where
    toVariant :: ByteString -> Variant
toVariant = Value -> Variant
Variant forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IsValue a => a -> Value
toValue
    fromVariant :: Variant -> Maybe ByteString
fromVariant (Variant Value
val) = forall a. IsValue a => Value -> Maybe a
fromValue Value
val

instance (Ord k, IsAtom k, IsValue v) => IsValue (Map k v) where
    typeOf_ :: Proxy (Map k v) -> Type
typeOf_ Proxy (Map k v)
_ = Type -> Type -> Type
TypeDictionary
        (forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy k))
        (forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy v))

    toValue :: Map k v -> Value
toValue Map k v
m = Type -> Type -> Map Atom Value -> Value
ValueMap Type
kt Type
vt (forall k' k v v'.
Ord k' =>
(k -> v -> (k', v')) -> Map k v -> Map k' v'
bimap forall {a} {a}. (IsAtom a, IsValue a) => a -> a -> (Atom, Value)
box Map k v
m) where
        kt :: Type
kt = forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy k)
        vt :: Type
vt = forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy v)
        box :: a -> a -> (Atom, Value)
box a
k a
v = (forall a. IsAtom a => a -> Atom
toAtom a
k, forall a. IsValue a => a -> Value
toValue a
v)

    fromValue :: Value -> Maybe (Map k v)
fromValue (ValueMap Type
_ Type
_ Map Atom Value
m) = forall (m :: * -> *) k' k v v'.
(Monad m, Ord k') =>
(k -> v -> m (k', v')) -> Map k v -> m (Map k' v')
bimapM forall {a} {b}.
(IsAtom a, IsValue b) =>
Atom -> Value -> Maybe (a, b)
unbox Map Atom Value
m where
        unbox :: Atom -> Value -> Maybe (a, b)
unbox Atom
k Value
v = do
            a
k' <- forall a. IsAtom a => Atom -> Maybe a
fromAtom Atom
k
            b
v' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
v
            forall (m :: * -> *) a. Monad m => a -> m a
return (a
k', b
v')
    fromValue Value
_ = forall a. Maybe a
Nothing

bimap :: Ord k' => (k -> v -> (k', v')) -> Map k v -> Map k' v'
bimap :: forall k' k v v'.
Ord k' =>
(k -> v -> (k', v')) -> Map k v -> Map k' v'
bimap k -> v -> (k', v')
f = forall k a. Ord k => [(k, a)] -> Map k a
Data.Map.fromList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map (\(k
k, v
v) -> k -> v -> (k', v')
f k
k v
v) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. Map k a -> [(k, a)]
Data.Map.toList

bimapM :: (Monad m, Ord k') => (k -> v -> m (k', v')) -> Map k v -> m (Map k' v')
bimapM :: forall (m :: * -> *) k' k v v'.
(Monad m, Ord k') =>
(k -> v -> m (k', v')) -> Map k v -> m (Map k' v')
bimapM k -> v -> m (k', v')
f = forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM forall k a. Ord k => [(k, a)] -> Map k a
Data.Map.fromList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (\(k
k, v
v) -> k -> v -> m (k', v')
f k
k v
v) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. Map k a -> [(k, a)]
Data.Map.toList

instance (Ord k, IsAtom k, IsValue v) => IsVariant (Map k v) where
    toVariant :: Map k v -> Variant
toVariant = Value -> Variant
Variant forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IsValue a => a -> Value
toValue
    fromVariant :: Variant -> Maybe (Map k v)
fromVariant (Variant Value
val) = forall a. IsValue a => Value -> Maybe a
fromValue Value
val

instance IsValue () where
  typeOf_ :: Proxy () -> Type
typeOf_ Proxy ()
_ = [Type] -> Type
TypeStructure []
  toValue :: () -> Value
toValue ()
_ = [Value] -> Value
ValueStructure []
  fromValue :: Value -> Maybe ()
fromValue (ValueStructure []) = forall (m :: * -> *) a. Monad m => a -> m a
return ()
  fromValue Value
_ = forall a. Maybe a
Nothing

instance IsVariant () where
  toVariant :: () -> Variant
toVariant () = Value -> Variant
Variant ([Value] -> Value
ValueStructure [])
  fromVariant :: Variant -> Maybe ()
fromVariant (Variant (ValueStructure [])) = forall a. a -> Maybe a
Just ()
  fromVariant Variant
_ = forall a. Maybe a
Nothing

instance (IsValue a1, IsValue a2) => IsValue (a1, a2) where
    typeOf_ :: Proxy (a1, a2) -> Type
typeOf_ Proxy (a1, a2)
_ = [Type] -> Type
TypeStructure
        [ forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a1)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a2)
        ]
    toValue :: (a1, a2) -> Value
toValue (a1
a1, a2
a2) = [Value] -> Value
ValueStructure [forall a. IsValue a => a -> Value
toValue a1
a1, forall a. IsValue a => a -> Value
toValue a2
a2]
    fromValue :: Value -> Maybe (a1, a2)
fromValue (ValueStructure [Value
a1, Value
a2]) = do
        a1
a1' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a1
        a2
a2' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a2
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2')
    fromValue Value
_ = forall a. Maybe a
Nothing

instance (IsVariant a1, IsVariant a2) => IsVariant (a1, a2) where
    toVariant :: (a1, a2) -> Variant
toVariant (a1
a1, a2
a2) = Value -> Variant
Variant ([Value] -> Value
ValueStructure [forall a. IsVariant a => a -> Value
varToVal a1
a1, forall a. IsVariant a => a -> Value
varToVal a2
a2])
    fromVariant :: Variant -> Maybe (a1, a2)
fromVariant (Variant (ValueStructure [Value
a1, Value
a2])) = do
        a1
a1' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a1
        a2
a2' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a2
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2')
    fromVariant Variant
_ = forall a. Maybe a
Nothing

varToVal :: IsVariant a => a -> Value
varToVal :: forall a. IsVariant a => a -> Value
varToVal a
a = case forall a. IsVariant a => a -> Variant
toVariant a
a of
    Variant Value
val -> Value
val

-- | Object paths are special strings, used to identify a particular object
-- exported from a D-Bus application.
--
-- Object paths must begin with a slash, and consist of alphanumeric
-- characters separated by slashes.
--
-- See
-- <http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-marshaling-object-path>
-- for details.
newtype ObjectPath = ObjectPath String
    deriving (ObjectPath -> ObjectPath -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ObjectPath -> ObjectPath -> Bool
$c/= :: ObjectPath -> ObjectPath -> Bool
== :: ObjectPath -> ObjectPath -> Bool
$c== :: ObjectPath -> ObjectPath -> Bool
Eq, Eq ObjectPath
ObjectPath -> ObjectPath -> Bool
ObjectPath -> ObjectPath -> Ordering
ObjectPath -> ObjectPath -> ObjectPath
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: ObjectPath -> ObjectPath -> ObjectPath
$cmin :: ObjectPath -> ObjectPath -> ObjectPath
max :: ObjectPath -> ObjectPath -> ObjectPath
$cmax :: ObjectPath -> ObjectPath -> ObjectPath
>= :: ObjectPath -> ObjectPath -> Bool
$c>= :: ObjectPath -> ObjectPath -> Bool
> :: ObjectPath -> ObjectPath -> Bool
$c> :: ObjectPath -> ObjectPath -> Bool
<= :: ObjectPath -> ObjectPath -> Bool
$c<= :: ObjectPath -> ObjectPath -> Bool
< :: ObjectPath -> ObjectPath -> Bool
$c< :: ObjectPath -> ObjectPath -> Bool
compare :: ObjectPath -> ObjectPath -> Ordering
$ccompare :: ObjectPath -> ObjectPath -> Ordering
Ord, Int -> ObjectPath -> ShowS
[ObjectPath] -> ShowS
ObjectPath -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ObjectPath] -> ShowS
$cshowList :: [ObjectPath] -> ShowS
show :: ObjectPath -> String
$cshow :: ObjectPath -> String
showsPrec :: Int -> ObjectPath -> ShowS
$cshowsPrec :: Int -> ObjectPath -> ShowS
Show, ObjectPath -> ()
forall a. (a -> ()) -> NFData a
rnf :: ObjectPath -> ()
$crnf :: ObjectPath -> ()
NFData)

pathElements :: ObjectPath -> [String]
pathElements :: ObjectPath -> [String]
pathElements = forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a. Foldable t => t a -> Bool
null) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => [a] -> [a] -> [[a]]
splitOn String
"/" forall b c a. (b -> c) -> (a -> b) -> a -> c
. coerce :: forall a b. Coercible a b => a -> b
coerce

fromElements :: [String] -> ObjectPath
fromElements :: [String] -> ObjectPath
fromElements [String]
elems = String -> ObjectPath
objectPath_ forall a b. (a -> b) -> a -> b
$ Char
'/'forall a. a -> [a] -> [a]
:forall a. [a] -> [[a]] -> [a]
intercalate String
"/" [String]
elems

formatObjectPath :: ObjectPath -> String
formatObjectPath :: ObjectPath -> String
formatObjectPath (ObjectPath String
s) = String
s

parseObjectPath :: MonadThrow m => String -> m ObjectPath
parseObjectPath :: forall (m :: * -> *). MonadThrow m => String -> m ObjectPath
parseObjectPath String
s = do
    forall (m :: * -> *) a. MonadThrow m => Parser a -> String -> m a
maybeParseString Parser ()
parserObjectPath String
s
    forall (m :: * -> *) a. Monad m => a -> m a
return (String -> ObjectPath
ObjectPath String
s)

objectPath_ :: String -> ObjectPath
objectPath_ :: String -> ObjectPath
objectPath_ = forall a. String -> (String -> Maybe a) -> String -> a
forceParse String
"object path" forall (m :: * -> *). MonadThrow m => String -> m ObjectPath
parseObjectPath

instance Data.String.IsString ObjectPath where
    fromString :: String -> ObjectPath
fromString = String -> ObjectPath
objectPath_

parserObjectPath :: Parsec.Parser ()
parserObjectPath :: Parser ()
parserObjectPath = forall {st}. GenParser Char st ()
root forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Parser ()
object where
    root :: GenParser Char st ()
root = forall tok st a. GenParser tok st a -> GenParser tok st a
Parsec.try forall a b. (a -> b) -> a -> b
$ do
        forall {st}. GenParser Char st ()
slash
        forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
Parsec.eof

    object :: Parser ()
object = do
        forall {st}. GenParser Char st ()
slash
        forall a b. Parser a -> Parser b -> Parser ()
skipSepBy1 forall {st}. GenParser Char st ()
element forall {st}. GenParser Char st ()
slash
        forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
Parsec.eof

    element :: ParsecT String u Identity ()
element = forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
Parsec.skipMany1 (forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
oneOf String
chars)

    slash :: ParsecT String u Identity ()
slash = forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
Parsec.char Char
'/' forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return ()
    chars :: String
chars = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [ [Char
'a'..Char
'z']
                   , [Char
'A'..Char
'Z']
                   , [Char
'0'..Char
'9']
                   , String
"_"]

-- | Interfaces are used to group a set of methods and signals within an
-- exported object. Interface names consist of alphanumeric characters
-- separated by periods.
--
-- See
-- <http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-interface>
-- for details.
newtype InterfaceName = InterfaceName String
    deriving (InterfaceName -> InterfaceName -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InterfaceName -> InterfaceName -> Bool
$c/= :: InterfaceName -> InterfaceName -> Bool
== :: InterfaceName -> InterfaceName -> Bool
$c== :: InterfaceName -> InterfaceName -> Bool
Eq, Eq InterfaceName
InterfaceName -> InterfaceName -> Bool
InterfaceName -> InterfaceName -> Ordering
InterfaceName -> InterfaceName -> InterfaceName
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: InterfaceName -> InterfaceName -> InterfaceName
$cmin :: InterfaceName -> InterfaceName -> InterfaceName
max :: InterfaceName -> InterfaceName -> InterfaceName
$cmax :: InterfaceName -> InterfaceName -> InterfaceName
>= :: InterfaceName -> InterfaceName -> Bool
$c>= :: InterfaceName -> InterfaceName -> Bool
> :: InterfaceName -> InterfaceName -> Bool
$c> :: InterfaceName -> InterfaceName -> Bool
<= :: InterfaceName -> InterfaceName -> Bool
$c<= :: InterfaceName -> InterfaceName -> Bool
< :: InterfaceName -> InterfaceName -> Bool
$c< :: InterfaceName -> InterfaceName -> Bool
compare :: InterfaceName -> InterfaceName -> Ordering
$ccompare :: InterfaceName -> InterfaceName -> Ordering
Ord, Int -> InterfaceName -> ShowS
[InterfaceName] -> ShowS
InterfaceName -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InterfaceName] -> ShowS
$cshowList :: [InterfaceName] -> ShowS
show :: InterfaceName -> String
$cshow :: InterfaceName -> String
showsPrec :: Int -> InterfaceName -> ShowS
$cshowsPrec :: Int -> InterfaceName -> ShowS
Show, InterfaceName -> ()
forall a. (a -> ()) -> NFData a
rnf :: InterfaceName -> ()
$crnf :: InterfaceName -> ()
NFData)

formatInterfaceName :: InterfaceName -> String
formatInterfaceName :: InterfaceName -> String
formatInterfaceName (InterfaceName String
s) = String
s

parseInterfaceName :: MonadThrow m => String -> m InterfaceName
parseInterfaceName :: forall (m :: * -> *). MonadThrow m => String -> m InterfaceName
parseInterfaceName String
s = do
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (forall (t :: * -> *) a. Foldable t => t a -> Int
length String
s forall a. Ord a => a -> a -> Bool
> Int
255) forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM forall a b. (a -> b) -> a -> b
$ String -> IOError
userError String
"name too long"
    forall (m :: * -> *) a. MonadThrow m => Parser a -> String -> m a
maybeParseString Parser ()
parserInterfaceName String
s
    forall (m :: * -> *) a. Monad m => a -> m a
return (String -> InterfaceName
InterfaceName String
s)

interfaceName_ :: String -> InterfaceName
interfaceName_ :: String -> InterfaceName
interfaceName_ = forall a. String -> (String -> Maybe a) -> String -> a
forceParse String
"interface name" forall (m :: * -> *). MonadThrow m => String -> m InterfaceName
parseInterfaceName

instance Data.String.IsString InterfaceName where
    fromString :: String -> InterfaceName
fromString = String -> InterfaceName
interfaceName_

instance IsVariant InterfaceName where
    toVariant :: InterfaceName -> Variant
toVariant = forall a. IsVariant a => a -> Variant
toVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. InterfaceName -> String
formatInterfaceName
    fromVariant :: Variant -> Maybe InterfaceName
fromVariant = forall a. IsVariant a => Variant -> Maybe a
fromVariant forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> forall (m :: * -> *). MonadThrow m => String -> m InterfaceName
parseInterfaceName

parserInterfaceName :: Parsec.Parser ()
parserInterfaceName :: Parser ()
parserInterfaceName = Parser ()
name forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
Parsec.eof where
    alpha :: String
alpha = [Char
'a'..Char
'z'] forall a. [a] -> [a] -> [a]
++ [Char
'A'..Char
'Z'] forall a. [a] -> [a] -> [a]
++ String
"_"
    alphanum :: String
alphanum = String
alpha forall a. [a] -> [a] -> [a]
++ [Char
'0'..Char
'9']
    element :: ParsecT String u Identity ()
element = do
        Char
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
oneOf String
alpha
        forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
Parsec.skipMany (forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
oneOf String
alphanum)
    name :: Parser ()
name = do
        forall {st}. GenParser Char st ()
element
        Char
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
Parsec.char Char
'.'
        forall a b. Parser a -> Parser b -> Parser ()
skipSepBy1 forall {st}. GenParser Char st ()
element (forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
Parsec.char Char
'.')

-- | Member names are used to identify a single method or signal within an
-- interface. Method names consist of alphanumeric characters.
--
-- See
-- <http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-member>
-- for details.
newtype MemberName = MemberName String
    deriving (MemberName -> MemberName -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MemberName -> MemberName -> Bool
$c/= :: MemberName -> MemberName -> Bool
== :: MemberName -> MemberName -> Bool
$c== :: MemberName -> MemberName -> Bool
Eq, Eq MemberName
MemberName -> MemberName -> Bool
MemberName -> MemberName -> Ordering
MemberName -> MemberName -> MemberName
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: MemberName -> MemberName -> MemberName
$cmin :: MemberName -> MemberName -> MemberName
max :: MemberName -> MemberName -> MemberName
$cmax :: MemberName -> MemberName -> MemberName
>= :: MemberName -> MemberName -> Bool
$c>= :: MemberName -> MemberName -> Bool
> :: MemberName -> MemberName -> Bool
$c> :: MemberName -> MemberName -> Bool
<= :: MemberName -> MemberName -> Bool
$c<= :: MemberName -> MemberName -> Bool
< :: MemberName -> MemberName -> Bool
$c< :: MemberName -> MemberName -> Bool
compare :: MemberName -> MemberName -> Ordering
$ccompare :: MemberName -> MemberName -> Ordering
Ord, Int -> MemberName -> ShowS
[MemberName] -> ShowS
MemberName -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MemberName] -> ShowS
$cshowList :: [MemberName] -> ShowS
show :: MemberName -> String
$cshow :: MemberName -> String
showsPrec :: Int -> MemberName -> ShowS
$cshowsPrec :: Int -> MemberName -> ShowS
Show, MemberName -> ()
forall a. (a -> ()) -> NFData a
rnf :: MemberName -> ()
$crnf :: MemberName -> ()
NFData)

formatMemberName :: MemberName -> String
formatMemberName :: MemberName -> String
formatMemberName (MemberName String
s) = String
s

parseMemberName :: MonadThrow m => String -> m MemberName
parseMemberName :: forall (m :: * -> *). MonadThrow m => String -> m MemberName
parseMemberName String
s = do
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (forall (t :: * -> *) a. Foldable t => t a -> Int
length String
s forall a. Ord a => a -> a -> Bool
> Int
255) forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM forall a b. (a -> b) -> a -> b
$ String -> IOError
userError String
"name too long"
    forall (m :: * -> *) a. MonadThrow m => Parser a -> String -> m a
maybeParseString Parser ()
parserMemberName String
s
    forall (m :: * -> *) a. Monad m => a -> m a
return (String -> MemberName
MemberName String
s)

memberName_ :: String -> MemberName
memberName_ :: String -> MemberName
memberName_ = forall a. String -> (String -> Maybe a) -> String -> a
forceParse String
"member name" forall (m :: * -> *). MonadThrow m => String -> m MemberName
parseMemberName

instance Data.String.IsString MemberName where
    fromString :: String -> MemberName
fromString = String -> MemberName
memberName_

instance IsVariant MemberName where
    toVariant :: MemberName -> Variant
toVariant = forall a. IsVariant a => a -> Variant
toVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. MemberName -> String
formatMemberName
    fromVariant :: Variant -> Maybe MemberName
fromVariant = forall a. IsVariant a => Variant -> Maybe a
fromVariant forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> forall (m :: * -> *). MonadThrow m => String -> m MemberName
parseMemberName

parserMemberName :: Parsec.Parser ()
parserMemberName :: Parser ()
parserMemberName = forall {st}. GenParser Char st ()
name forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
Parsec.eof where
    alpha :: String
alpha = [Char
'a'..Char
'z'] forall a. [a] -> [a] -> [a]
++ [Char
'A'..Char
'Z'] forall a. [a] -> [a] -> [a]
++ String
"_"
    alphanum :: String
alphanum = String
alpha forall a. [a] -> [a] -> [a]
++ [Char
'0'..Char
'9']
    name :: ParsecT String u Identity ()
name = do
        Char
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
oneOf String
alpha
        forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
Parsec.skipMany (forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
oneOf String
alphanum)

-- | Error names are used to identify which type of error was returned from
-- a method call. Error names consist of alphanumeric characters
-- separated by periods.
--
-- See
-- <http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-error>
-- for details.
newtype ErrorName = ErrorName String
    deriving (ErrorName -> ErrorName -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ErrorName -> ErrorName -> Bool
$c/= :: ErrorName -> ErrorName -> Bool
== :: ErrorName -> ErrorName -> Bool
$c== :: ErrorName -> ErrorName -> Bool
Eq, Eq ErrorName
ErrorName -> ErrorName -> Bool
ErrorName -> ErrorName -> Ordering
ErrorName -> ErrorName -> ErrorName
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: ErrorName -> ErrorName -> ErrorName
$cmin :: ErrorName -> ErrorName -> ErrorName
max :: ErrorName -> ErrorName -> ErrorName
$cmax :: ErrorName -> ErrorName -> ErrorName
>= :: ErrorName -> ErrorName -> Bool
$c>= :: ErrorName -> ErrorName -> Bool
> :: ErrorName -> ErrorName -> Bool
$c> :: ErrorName -> ErrorName -> Bool
<= :: ErrorName -> ErrorName -> Bool
$c<= :: ErrorName -> ErrorName -> Bool
< :: ErrorName -> ErrorName -> Bool
$c< :: ErrorName -> ErrorName -> Bool
compare :: ErrorName -> ErrorName -> Ordering
$ccompare :: ErrorName -> ErrorName -> Ordering
Ord, Int -> ErrorName -> ShowS
[ErrorName] -> ShowS
ErrorName -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ErrorName] -> ShowS
$cshowList :: [ErrorName] -> ShowS
show :: ErrorName -> String
$cshow :: ErrorName -> String
showsPrec :: Int -> ErrorName -> ShowS
$cshowsPrec :: Int -> ErrorName -> ShowS
Show, ErrorName -> ()
forall a. (a -> ()) -> NFData a
rnf :: ErrorName -> ()
$crnf :: ErrorName -> ()
NFData)

formatErrorName :: ErrorName -> String
formatErrorName :: ErrorName -> String
formatErrorName (ErrorName String
s) = String
s

parseErrorName :: MonadThrow m => String -> m ErrorName
parseErrorName :: forall (m :: * -> *). MonadThrow m => String -> m ErrorName
parseErrorName String
s = do
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (forall (t :: * -> *) a. Foldable t => t a -> Int
length String
s forall a. Ord a => a -> a -> Bool
> Int
255) forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM forall a b. (a -> b) -> a -> b
$ String -> IOError
userError String
"name too long"
    forall (m :: * -> *) a. MonadThrow m => Parser a -> String -> m a
maybeParseString Parser ()
parserInterfaceName String
s
    forall (m :: * -> *) a. Monad m => a -> m a
return (String -> ErrorName
ErrorName String
s)

errorName_ :: String -> ErrorName
errorName_ :: String -> ErrorName
errorName_ = forall a. String -> (String -> Maybe a) -> String -> a
forceParse String
"error name" forall (m :: * -> *). MonadThrow m => String -> m ErrorName
parseErrorName

instance Data.String.IsString ErrorName where
    fromString :: String -> ErrorName
fromString = String -> ErrorName
errorName_

instance IsVariant ErrorName where
    toVariant :: ErrorName -> Variant
toVariant = forall a. IsVariant a => a -> Variant
toVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. ErrorName -> String
formatErrorName
    fromVariant :: Variant -> Maybe ErrorName
fromVariant = forall a. IsVariant a => Variant -> Maybe a
fromVariant forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> forall (m :: * -> *). MonadThrow m => String -> m ErrorName
parseErrorName

-- | Bus names are used to identify particular clients on the message bus.
-- A bus name may be either /unique/ or /well-known/, where unique names
-- start with a colon. Bus names consist of alphanumeric characters separated
-- by periods.
--
-- See
-- <http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-bus>
-- for details.
newtype BusName = BusName String
    deriving (BusName -> BusName -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BusName -> BusName -> Bool
$c/= :: BusName -> BusName -> Bool
== :: BusName -> BusName -> Bool
$c== :: BusName -> BusName -> Bool
Eq, Eq BusName
BusName -> BusName -> Bool
BusName -> BusName -> Ordering
BusName -> BusName -> BusName
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: BusName -> BusName -> BusName
$cmin :: BusName -> BusName -> BusName
max :: BusName -> BusName -> BusName
$cmax :: BusName -> BusName -> BusName
>= :: BusName -> BusName -> Bool
$c>= :: BusName -> BusName -> Bool
> :: BusName -> BusName -> Bool
$c> :: BusName -> BusName -> Bool
<= :: BusName -> BusName -> Bool
$c<= :: BusName -> BusName -> Bool
< :: BusName -> BusName -> Bool
$c< :: BusName -> BusName -> Bool
compare :: BusName -> BusName -> Ordering
$ccompare :: BusName -> BusName -> Ordering
Ord, Int -> BusName -> ShowS
[BusName] -> ShowS
BusName -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BusName] -> ShowS
$cshowList :: [BusName] -> ShowS
show :: BusName -> String
$cshow :: BusName -> String
showsPrec :: Int -> BusName -> ShowS
$cshowsPrec :: Int -> BusName -> ShowS
Show, BusName -> ()
forall a. (a -> ()) -> NFData a
rnf :: BusName -> ()
$crnf :: BusName -> ()
NFData)

formatBusName :: BusName -> String
formatBusName :: BusName -> String
formatBusName (BusName String
s) = String
s

parseBusName :: MonadThrow m => String -> m BusName
parseBusName :: forall (m :: * -> *). MonadThrow m => String -> m BusName
parseBusName String
s = do
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (forall (t :: * -> *) a. Foldable t => t a -> Int
length String
s forall a. Ord a => a -> a -> Bool
> Int
255) forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM forall a b. (a -> b) -> a -> b
$ String -> IOError
userError String
"name too long"
    forall (m :: * -> *) a. MonadThrow m => Parser a -> String -> m a
maybeParseString Parser ()
parserBusName String
s
    forall (m :: * -> *) a. Monad m => a -> m a
return (String -> BusName
BusName String
s)

busName_ :: String -> BusName
busName_ :: String -> BusName
busName_ = forall a. String -> (String -> Maybe a) -> String -> a
forceParse String
"bus name" forall (m :: * -> *). MonadThrow m => String -> m BusName
parseBusName

instance Data.String.IsString BusName where
    fromString :: String -> BusName
fromString = String -> BusName
busName_

instance IsVariant BusName where
    toVariant :: BusName -> Variant
toVariant = forall a. IsVariant a => a -> Variant
toVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. BusName -> String
formatBusName
    fromVariant :: Variant -> Maybe BusName
fromVariant = forall a. IsVariant a => Variant -> Maybe a
fromVariant forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> forall (m :: * -> *). MonadThrow m => String -> m BusName
parseBusName

parserBusName :: Parsec.Parser ()
parserBusName :: Parser ()
parserBusName = Parser ()
name forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
Parsec.eof where
    alpha :: String
alpha = [Char
'a'..Char
'z'] forall a. [a] -> [a] -> [a]
++ [Char
'A'..Char
'Z'] forall a. [a] -> [a] -> [a]
++ String
"_-"
    alphanum :: String
alphanum = String
alpha forall a. [a] -> [a] -> [a]
++ [Char
'0'..Char
'9']

    name :: Parser ()
name = Parser ()
unique forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Parser ()
wellKnown
    unique :: Parser ()
unique = do
        Char
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
Parsec.char Char
':'
        String -> Parser ()
elements String
alphanum

    wellKnown :: Parser ()
wellKnown = String -> Parser ()
elements String
alpha

    elements :: [Char] -> Parsec.Parser ()
    elements :: String -> Parser ()
elements String
start = do
        String -> Parser ()
element String
start
        forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
Parsec.skipMany1 forall a b. (a -> b) -> a -> b
$ do
            Char
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
Parsec.char Char
'.'
            String -> Parser ()
element String
start

    element :: [Char] -> Parsec.Parser ()
    element :: String -> Parser ()
element String
start = do
        Char
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
oneOf String
start
        forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
Parsec.skipMany (forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
oneOf String
alphanum)

-- | A D-Bus Structure is a container type similar to Haskell tuples, storing
-- values of any type that is convertable to 'IsVariant'. A Structure may
-- contain up to 255 values.
--
-- Most users can use the 'IsVariant' instance for tuples to extract the
-- values of a structure. This type is for very large structures, which may
-- be awkward to work with as tuples.
newtype Structure = Structure [Value]
    deriving (Structure -> Structure -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Structure -> Structure -> Bool
$c/= :: Structure -> Structure -> Bool
== :: Structure -> Structure -> Bool
$c== :: Structure -> Structure -> Bool
Eq)

instance Show Structure where
    show :: Structure -> String
show (Structure [Value]
xs) = Bool -> Value -> String
showValue Bool
True ([Value] -> Value
ValueStructure [Value]
xs)

instance IsVariant Structure where
    toVariant :: Structure -> Variant
toVariant (Structure [Value]
xs) = Value -> Variant
Variant ([Value] -> Value
ValueStructure [Value]
xs)
    fromVariant :: Variant -> Maybe Structure
fromVariant (Variant (ValueStructure [Value]
xs)) = forall a. a -> Maybe a
Just ([Value] -> Structure
Structure [Value]
xs)
    fromVariant Variant
_ = forall a. Maybe a
Nothing

structureItems :: Structure -> [Variant]
structureItems :: Structure -> [Variant]
structureItems (Structure [Value]
xs) = forall a b. (a -> b) -> [a] -> [b]
map Value -> Variant
Variant [Value]
xs

-- | A D-Bus Array is a container type similar to Haskell lists, storing
-- zero or more values of a single D-Bus type.
--
-- Most users can use the 'IsVariant' instance for lists or vectors to extract
-- the values of an array. This type is for advanced use cases, where the user
-- wants to convert array values to Haskell types that are not instances of
-- 'IsValue'.
data Array
    = Array Type (Vector Value)
    | ArrayBytes BS.ByteString

instance Show Array where
    show :: Array -> String
show (Array Type
t Vector Value
xs) = Bool -> Value -> String
showValue Bool
True (Type -> Vector Value -> Value
ValueVector Type
t Vector Value
xs)
    show (ArrayBytes ByteString
xs) = Bool -> Value -> String
showValue Bool
True (ByteString -> Value
ValueBytes ByteString
xs)

instance Eq Array where
    Array
x == :: Array -> Array -> Bool
== Array
y = Array -> Either ByteString (Type, Vector Value)
norm Array
x forall a. Eq a => a -> a -> Bool
== Array -> Either ByteString (Type, Vector Value)
norm Array
y where
        norm :: Array -> Either ByteString (Type, Vector Value)
norm (Array Type
TypeWord8 Vector Value
xs) = forall a b. a -> Either a b
Left (Vector Value -> ByteString
vectorToBytes Vector Value
xs)
        norm (Array Type
t Vector Value
xs) = forall a b. b -> Either a b
Right (Type
t, Vector Value
xs)
        norm (ArrayBytes ByteString
xs) = forall a b. a -> Either a b
Left ByteString
xs

instance IsVariant Array where
    toVariant :: Array -> Variant
toVariant (Array Type
t Vector Value
xs) = Value -> Variant
Variant (Type -> Vector Value -> Value
ValueVector Type
t Vector Value
xs)
    toVariant (ArrayBytes ByteString
bs) = Value -> Variant
Variant (ByteString -> Value
ValueBytes ByteString
bs)
    fromVariant :: Variant -> Maybe Array
fromVariant (Variant (ValueVector Type
t Vector Value
xs)) = forall a. a -> Maybe a
Just (Type -> Vector Value -> Array
Array Type
t Vector Value
xs)
    fromVariant (Variant (ValueBytes ByteString
bs)) = forall a. a -> Maybe a
Just (ByteString -> Array
ArrayBytes ByteString
bs)
    fromVariant Variant
_ = forall a. Maybe a
Nothing

arrayItems :: Array -> [Variant]
arrayItems :: Array -> [Variant]
arrayItems (Array Type
_ Vector Value
xs) = forall a b. (a -> b) -> [a] -> [b]
map Value -> Variant
Variant (forall a. Vector a -> [a]
Data.Vector.toList Vector Value
xs)
arrayItems (ArrayBytes ByteString
bs) = forall a b. (a -> b) -> [a] -> [b]
map forall a. IsVariant a => a -> Variant
toVariant (ByteString -> [Word8]
BS.unpack ByteString
bs)

-- | A D-Bus Dictionary is a container type similar to Haskell maps, storing
-- zero or more associations between keys and values.
--
-- Most users can use the 'IsVariant' instance for maps to extract the values
-- of a dictionary. This type is for advanced use cases, where the user
-- wants to convert dictionary items to Haskell types that are not instances
-- of 'IsValue'.
data Dictionary = Dictionary Type Type (Map Atom Value)
    deriving (Dictionary -> Dictionary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Dictionary -> Dictionary -> Bool
$c/= :: Dictionary -> Dictionary -> Bool
== :: Dictionary -> Dictionary -> Bool
$c== :: Dictionary -> Dictionary -> Bool
Eq)

instance Show Dictionary where
    show :: Dictionary -> String
show (Dictionary Type
kt Type
vt Map Atom Value
xs) = Bool -> Value -> String
showValue Bool
True (Type -> Type -> Map Atom Value -> Value
ValueMap Type
kt Type
vt Map Atom Value
xs)

instance IsVariant Dictionary where
    toVariant :: Dictionary -> Variant
toVariant (Dictionary Type
kt Type
vt Map Atom Value
xs) = Value -> Variant
Variant (Type -> Type -> Map Atom Value -> Value
ValueMap Type
kt Type
vt Map Atom Value
xs)
    fromVariant :: Variant -> Maybe Dictionary
fromVariant (Variant (ValueMap Type
kt Type
vt Map Atom Value
xs)) = forall a. a -> Maybe a
Just (Type -> Type -> Map Atom Value -> Dictionary
Dictionary Type
kt Type
vt Map Atom Value
xs)
    fromVariant Variant
_ = forall a. Maybe a
Nothing

dictionaryItems :: Dictionary -> [(Variant, Variant)]
dictionaryItems :: Dictionary -> [(Variant, Variant)]
dictionaryItems (Dictionary Type
_ Type
_ Map Atom Value
xs) = do
    (Atom
k, Value
v) <- forall k a. Map k a -> [(k, a)]
Data.Map.toList Map Atom Value
xs
    forall (m :: * -> *) a. Monad m => a -> m a
return (Value -> Variant
Variant (Atom -> Value
ValueAtom Atom
k), Value -> Variant
Variant Value
v)

instance (IsValue a1, IsValue a2, IsValue a3) => IsValue (a1, a2, a3) where
    typeOf_ :: Proxy (a1, a2, a3) -> Type
typeOf_ Proxy (a1, a2, a3)
_ = [Type] -> Type
TypeStructure
        [ forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a1)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a2)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a3)
        ]
    toValue :: (a1, a2, a3) -> Value
toValue (a1
a1, a2
a2, a3
a3) = [Value] -> Value
ValueStructure [forall a. IsValue a => a -> Value
toValue a1
a1, forall a. IsValue a => a -> Value
toValue a2
a2, forall a. IsValue a => a -> Value
toValue a3
a3]
    fromValue :: Value -> Maybe (a1, a2, a3)
fromValue (ValueStructure [Value
a1, Value
a2, Value
a3]) = do
        a1
a1' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a1
        a2
a2' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a2
        a3
a3' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a3
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3')
    fromValue Value
_ = forall a. Maybe a
Nothing

instance (IsValue a1, IsValue a2, IsValue a3, IsValue a4) => IsValue (a1, a2, a3, a4) where
    typeOf_ :: Proxy (a1, a2, a3, a4) -> Type
typeOf_ Proxy (a1, a2, a3, a4)
_ = [Type] -> Type
TypeStructure
        [ forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a1)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a2)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a3)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a4)
        ]
    toValue :: (a1, a2, a3, a4) -> Value
toValue (a1
a1, a2
a2, a3
a3, a4
a4) = [Value] -> Value
ValueStructure [forall a. IsValue a => a -> Value
toValue a1
a1, forall a. IsValue a => a -> Value
toValue a2
a2, forall a. IsValue a => a -> Value
toValue a3
a3, forall a. IsValue a => a -> Value
toValue a4
a4]
    fromValue :: Value -> Maybe (a1, a2, a3, a4)
fromValue (ValueStructure [Value
a1, Value
a2, Value
a3, Value
a4]) = do
        a1
a1' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a1
        a2
a2' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a2
        a3
a3' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a3
        a4
a4' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a4
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3', a4
a4')
    fromValue Value
_ = forall a. Maybe a
Nothing

instance (IsValue a1, IsValue a2, IsValue a3, IsValue a4, IsValue a5) => IsValue (a1, a2, a3, a4, a5) where
    typeOf_ :: Proxy (a1, a2, a3, a4, a5) -> Type
typeOf_ Proxy (a1, a2, a3, a4, a5)
_ = [Type] -> Type
TypeStructure
        [ forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a1)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a2)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a3)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a4)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a5)
        ]
    toValue :: (a1, a2, a3, a4, a5) -> Value
toValue (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5) = [Value] -> Value
ValueStructure [forall a. IsValue a => a -> Value
toValue a1
a1, forall a. IsValue a => a -> Value
toValue a2
a2, forall a. IsValue a => a -> Value
toValue a3
a3, forall a. IsValue a => a -> Value
toValue a4
a4, forall a. IsValue a => a -> Value
toValue a5
a5]
    fromValue :: Value -> Maybe (a1, a2, a3, a4, a5)
fromValue (ValueStructure [Value
a1, Value
a2, Value
a3, Value
a4, Value
a5]) = do
        a1
a1' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a1
        a2
a2' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a2
        a3
a3' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a3
        a4
a4' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a4
        a5
a5' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a5
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3', a4
a4', a5
a5')
    fromValue Value
_ = forall a. Maybe a
Nothing

instance (IsValue a1, IsValue a2, IsValue a3, IsValue a4, IsValue a5, IsValue a6) => IsValue (a1, a2, a3, a4, a5, a6) where
    typeOf_ :: Proxy (a1, a2, a3, a4, a5, a6) -> Type
typeOf_ Proxy (a1, a2, a3, a4, a5, a6)
_ = [Type] -> Type
TypeStructure
        [ forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a1)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a2)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a3)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a4)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a5)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a6)
        ]
    toValue :: (a1, a2, a3, a4, a5, a6) -> Value
toValue (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6) = [Value] -> Value
ValueStructure [forall a. IsValue a => a -> Value
toValue a1
a1, forall a. IsValue a => a -> Value
toValue a2
a2, forall a. IsValue a => a -> Value
toValue a3
a3, forall a. IsValue a => a -> Value
toValue a4
a4, forall a. IsValue a => a -> Value
toValue a5
a5, forall a. IsValue a => a -> Value
toValue a6
a6]
    fromValue :: Value -> Maybe (a1, a2, a3, a4, a5, a6)
fromValue (ValueStructure [Value
a1, Value
a2, Value
a3, Value
a4, Value
a5, Value
a6]) = do
        a1
a1' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a1
        a2
a2' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a2
        a3
a3' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a3
        a4
a4' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a4
        a5
a5' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a5
        a6
a6' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a6
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3', a4
a4', a5
a5', a6
a6')
    fromValue Value
_ = forall a. Maybe a
Nothing

instance (IsValue a1, IsValue a2, IsValue a3, IsValue a4, IsValue a5, IsValue a6, IsValue a7) => IsValue (a1, a2, a3, a4, a5, a6, a7) where
    typeOf_ :: Proxy (a1, a2, a3, a4, a5, a6, a7) -> Type
typeOf_ Proxy (a1, a2, a3, a4, a5, a6, a7)
_ = [Type] -> Type
TypeStructure
        [ forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a1)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a2)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a3)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a4)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a5)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a6)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a7)
        ]
    toValue :: (a1, a2, a3, a4, a5, a6, a7) -> Value
toValue (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6, a7
a7) = [Value] -> Value
ValueStructure [forall a. IsValue a => a -> Value
toValue a1
a1, forall a. IsValue a => a -> Value
toValue a2
a2, forall a. IsValue a => a -> Value
toValue a3
a3, forall a. IsValue a => a -> Value
toValue a4
a4, forall a. IsValue a => a -> Value
toValue a5
a5, forall a. IsValue a => a -> Value
toValue a6
a6, forall a. IsValue a => a -> Value
toValue a7
a7]
    fromValue :: Value -> Maybe (a1, a2, a3, a4, a5, a6, a7)
fromValue (ValueStructure [Value
a1, Value
a2, Value
a3, Value
a4, Value
a5, Value
a6, Value
a7]) = do
        a1
a1' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a1
        a2
a2' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a2
        a3
a3' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a3
        a4
a4' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a4
        a5
a5' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a5
        a6
a6' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a6
        a7
a7' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a7
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3', a4
a4', a5
a5', a6
a6', a7
a7')
    fromValue Value
_ = forall a. Maybe a
Nothing

instance (IsValue a1, IsValue a2, IsValue a3, IsValue a4, IsValue a5, IsValue a6, IsValue a7, IsValue a8) => IsValue (a1, a2, a3, a4, a5, a6, a7, a8) where
    typeOf_ :: Proxy (a1, a2, a3, a4, a5, a6, a7, a8) -> Type
typeOf_ Proxy (a1, a2, a3, a4, a5, a6, a7, a8)
_ = [Type] -> Type
TypeStructure
        [ forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a1)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a2)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a3)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a4)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a5)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a6)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a7)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a8)
        ]
    toValue :: (a1, a2, a3, a4, a5, a6, a7, a8) -> Value
toValue (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6, a7
a7, a8
a8) = [Value] -> Value
ValueStructure [forall a. IsValue a => a -> Value
toValue a1
a1, forall a. IsValue a => a -> Value
toValue a2
a2, forall a. IsValue a => a -> Value
toValue a3
a3, forall a. IsValue a => a -> Value
toValue a4
a4, forall a. IsValue a => a -> Value
toValue a5
a5, forall a. IsValue a => a -> Value
toValue a6
a6, forall a. IsValue a => a -> Value
toValue a7
a7, forall a. IsValue a => a -> Value
toValue a8
a8]
    fromValue :: Value -> Maybe (a1, a2, a3, a4, a5, a6, a7, a8)
fromValue (ValueStructure [Value
a1, Value
a2, Value
a3, Value
a4, Value
a5, Value
a6, Value
a7, Value
a8]) = do
        a1
a1' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a1
        a2
a2' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a2
        a3
a3' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a3
        a4
a4' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a4
        a5
a5' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a5
        a6
a6' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a6
        a7
a7' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a7
        a8
a8' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a8
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3', a4
a4', a5
a5', a6
a6', a7
a7', a8
a8')
    fromValue Value
_ = forall a. Maybe a
Nothing

instance (IsValue a1, IsValue a2, IsValue a3, IsValue a4, IsValue a5, IsValue a6, IsValue a7, IsValue a8, IsValue a9) => IsValue (a1, a2, a3, a4, a5, a6, a7, a8, a9) where
    typeOf_ :: Proxy (a1, a2, a3, a4, a5, a6, a7, a8, a9) -> Type
typeOf_ Proxy (a1, a2, a3, a4, a5, a6, a7, a8, a9)
_ = [Type] -> Type
TypeStructure
        [ forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a1)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a2)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a3)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a4)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a5)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a6)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a7)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a8)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a9)
        ]
    toValue :: (a1, a2, a3, a4, a5, a6, a7, a8, a9) -> Value
toValue (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6, a7
a7, a8
a8, a9
a9) = [Value] -> Value
ValueStructure [forall a. IsValue a => a -> Value
toValue a1
a1, forall a. IsValue a => a -> Value
toValue a2
a2, forall a. IsValue a => a -> Value
toValue a3
a3, forall a. IsValue a => a -> Value
toValue a4
a4, forall a. IsValue a => a -> Value
toValue a5
a5, forall a. IsValue a => a -> Value
toValue a6
a6, forall a. IsValue a => a -> Value
toValue a7
a7, forall a. IsValue a => a -> Value
toValue a8
a8, forall a. IsValue a => a -> Value
toValue a9
a9]
    fromValue :: Value -> Maybe (a1, a2, a3, a4, a5, a6, a7, a8, a9)
fromValue (ValueStructure [Value
a1, Value
a2, Value
a3, Value
a4, Value
a5, Value
a6, Value
a7, Value
a8, Value
a9]) = do
        a1
a1' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a1
        a2
a2' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a2
        a3
a3' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a3
        a4
a4' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a4
        a5
a5' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a5
        a6
a6' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a6
        a7
a7' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a7
        a8
a8' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a8
        a9
a9' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a9
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3', a4
a4', a5
a5', a6
a6', a7
a7', a8
a8', a9
a9')
    fromValue Value
_ = forall a. Maybe a
Nothing

instance (IsValue a1, IsValue a2, IsValue a3, IsValue a4, IsValue a5, IsValue a6, IsValue a7, IsValue a8, IsValue a9, IsValue a10) => IsValue (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) where
    typeOf_ :: Proxy (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) -> Type
typeOf_ Proxy (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
_ = [Type] -> Type
TypeStructure
        [ forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a1)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a2)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a3)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a4)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a5)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a6)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a7)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a8)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a9)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a10)
        ]
    toValue :: (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) -> Value
toValue (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6, a7
a7, a8
a8, a9
a9, a10
a10) = [Value] -> Value
ValueStructure [forall a. IsValue a => a -> Value
toValue a1
a1, forall a. IsValue a => a -> Value
toValue a2
a2, forall a. IsValue a => a -> Value
toValue a3
a3, forall a. IsValue a => a -> Value
toValue a4
a4, forall a. IsValue a => a -> Value
toValue a5
a5, forall a. IsValue a => a -> Value
toValue a6
a6, forall a. IsValue a => a -> Value
toValue a7
a7, forall a. IsValue a => a -> Value
toValue a8
a8, forall a. IsValue a => a -> Value
toValue a9
a9, forall a. IsValue a => a -> Value
toValue a10
a10]
    fromValue :: Value -> Maybe (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
fromValue (ValueStructure [Value
a1, Value
a2, Value
a3, Value
a4, Value
a5, Value
a6, Value
a7, Value
a8, Value
a9, Value
a10]) = do
        a1
a1' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a1
        a2
a2' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a2
        a3
a3' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a3
        a4
a4' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a4
        a5
a5' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a5
        a6
a6' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a6
        a7
a7' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a7
        a8
a8' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a8
        a9
a9' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a9
        a10
a10' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a10
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3', a4
a4', a5
a5', a6
a6', a7
a7', a8
a8', a9
a9', a10
a10')
    fromValue Value
_ = forall a. Maybe a
Nothing

instance (IsValue a1, IsValue a2, IsValue a3, IsValue a4, IsValue a5, IsValue a6, IsValue a7, IsValue a8, IsValue a9, IsValue a10, IsValue a11) => IsValue (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) where
    typeOf_ :: Proxy (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) -> Type
typeOf_ Proxy (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11)
_ = [Type] -> Type
TypeStructure
        [ forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a1)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a2)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a3)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a4)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a5)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a6)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a7)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a8)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a9)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a10)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a11)
        ]
    toValue :: (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) -> Value
toValue (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6, a7
a7, a8
a8, a9
a9, a10
a10, a11
a11) = [Value] -> Value
ValueStructure [forall a. IsValue a => a -> Value
toValue a1
a1, forall a. IsValue a => a -> Value
toValue a2
a2, forall a. IsValue a => a -> Value
toValue a3
a3, forall a. IsValue a => a -> Value
toValue a4
a4, forall a. IsValue a => a -> Value
toValue a5
a5, forall a. IsValue a => a -> Value
toValue a6
a6, forall a. IsValue a => a -> Value
toValue a7
a7, forall a. IsValue a => a -> Value
toValue a8
a8, forall a. IsValue a => a -> Value
toValue a9
a9, forall a. IsValue a => a -> Value
toValue a10
a10, forall a. IsValue a => a -> Value
toValue a11
a11]
    fromValue :: Value -> Maybe (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11)
fromValue (ValueStructure [Value
a1, Value
a2, Value
a3, Value
a4, Value
a5, Value
a6, Value
a7, Value
a8, Value
a9, Value
a10, Value
a11]) = do
        a1
a1' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a1
        a2
a2' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a2
        a3
a3' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a3
        a4
a4' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a4
        a5
a5' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a5
        a6
a6' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a6
        a7
a7' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a7
        a8
a8' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a8
        a9
a9' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a9
        a10
a10' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a10
        a11
a11' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a11
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3', a4
a4', a5
a5', a6
a6', a7
a7', a8
a8', a9
a9', a10
a10', a11
a11')
    fromValue Value
_ = forall a. Maybe a
Nothing

instance (IsValue a1, IsValue a2, IsValue a3, IsValue a4, IsValue a5, IsValue a6, IsValue a7, IsValue a8, IsValue a9, IsValue a10, IsValue a11, IsValue a12) => IsValue (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) where
    typeOf_ :: Proxy (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) -> Type
typeOf_ Proxy (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12)
_ = [Type] -> Type
TypeStructure
        [ forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a1)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a2)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a3)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a4)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a5)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a6)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a7)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a8)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a9)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a10)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a11)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a12)
        ]
    toValue :: (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) -> Value
toValue (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6, a7
a7, a8
a8, a9
a9, a10
a10, a11
a11, a12
a12) = [Value] -> Value
ValueStructure [forall a. IsValue a => a -> Value
toValue a1
a1, forall a. IsValue a => a -> Value
toValue a2
a2, forall a. IsValue a => a -> Value
toValue a3
a3, forall a. IsValue a => a -> Value
toValue a4
a4, forall a. IsValue a => a -> Value
toValue a5
a5, forall a. IsValue a => a -> Value
toValue a6
a6, forall a. IsValue a => a -> Value
toValue a7
a7, forall a. IsValue a => a -> Value
toValue a8
a8, forall a. IsValue a => a -> Value
toValue a9
a9, forall a. IsValue a => a -> Value
toValue a10
a10, forall a. IsValue a => a -> Value
toValue a11
a11, forall a. IsValue a => a -> Value
toValue a12
a12]
    fromValue :: Value -> Maybe (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12)
fromValue (ValueStructure [Value
a1, Value
a2, Value
a3, Value
a4, Value
a5, Value
a6, Value
a7, Value
a8, Value
a9, Value
a10, Value
a11, Value
a12]) = do
        a1
a1' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a1
        a2
a2' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a2
        a3
a3' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a3
        a4
a4' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a4
        a5
a5' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a5
        a6
a6' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a6
        a7
a7' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a7
        a8
a8' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a8
        a9
a9' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a9
        a10
a10' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a10
        a11
a11' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a11
        a12
a12' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a12
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3', a4
a4', a5
a5', a6
a6', a7
a7', a8
a8', a9
a9', a10
a10', a11
a11', a12
a12')
    fromValue Value
_ = forall a. Maybe a
Nothing

instance (IsValue a1, IsValue a2, IsValue a3, IsValue a4, IsValue a5, IsValue a6, IsValue a7, IsValue a8, IsValue a9, IsValue a10, IsValue a11, IsValue a12, IsValue a13) => IsValue (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) where
    typeOf_ :: Proxy (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13)
-> Type
typeOf_ Proxy (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13)
_ = [Type] -> Type
TypeStructure
        [ forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a1)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a2)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a3)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a4)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a5)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a6)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a7)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a8)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a9)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a10)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a11)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a12)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a13)
        ]
    toValue :: (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) -> Value
toValue (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6, a7
a7, a8
a8, a9
a9, a10
a10, a11
a11, a12
a12, a13
a13) = [Value] -> Value
ValueStructure [forall a. IsValue a => a -> Value
toValue a1
a1, forall a. IsValue a => a -> Value
toValue a2
a2, forall a. IsValue a => a -> Value
toValue a3
a3, forall a. IsValue a => a -> Value
toValue a4
a4, forall a. IsValue a => a -> Value
toValue a5
a5, forall a. IsValue a => a -> Value
toValue a6
a6, forall a. IsValue a => a -> Value
toValue a7
a7, forall a. IsValue a => a -> Value
toValue a8
a8, forall a. IsValue a => a -> Value
toValue a9
a9, forall a. IsValue a => a -> Value
toValue a10
a10, forall a. IsValue a => a -> Value
toValue a11
a11, forall a. IsValue a => a -> Value
toValue a12
a12, forall a. IsValue a => a -> Value
toValue a13
a13]
    fromValue :: Value
-> Maybe (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13)
fromValue (ValueStructure [Value
a1, Value
a2, Value
a3, Value
a4, Value
a5, Value
a6, Value
a7, Value
a8, Value
a9, Value
a10, Value
a11, Value
a12, Value
a13]) = do
        a1
a1' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a1
        a2
a2' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a2
        a3
a3' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a3
        a4
a4' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a4
        a5
a5' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a5
        a6
a6' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a6
        a7
a7' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a7
        a8
a8' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a8
        a9
a9' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a9
        a10
a10' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a10
        a11
a11' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a11
        a12
a12' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a12
        a13
a13' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a13
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3', a4
a4', a5
a5', a6
a6', a7
a7', a8
a8', a9
a9', a10
a10', a11
a11', a12
a12', a13
a13')
    fromValue Value
_ = forall a. Maybe a
Nothing

instance (IsValue a1, IsValue a2, IsValue a3, IsValue a4, IsValue a5, IsValue a6, IsValue a7, IsValue a8, IsValue a9, IsValue a10, IsValue a11, IsValue a12, IsValue a13, IsValue a14) => IsValue (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14) where
    typeOf_ :: Proxy (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14)
-> Type
typeOf_ Proxy (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14)
_ = [Type] -> Type
TypeStructure
        [ forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a1)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a2)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a3)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a4)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a5)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a6)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a7)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a8)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a9)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a10)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a11)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a12)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a13)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a14)
        ]
    toValue :: (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14)
-> Value
toValue (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6, a7
a7, a8
a8, a9
a9, a10
a10, a11
a11, a12
a12, a13
a13, a14
a14) = [Value] -> Value
ValueStructure [forall a. IsValue a => a -> Value
toValue a1
a1, forall a. IsValue a => a -> Value
toValue a2
a2, forall a. IsValue a => a -> Value
toValue a3
a3, forall a. IsValue a => a -> Value
toValue a4
a4, forall a. IsValue a => a -> Value
toValue a5
a5, forall a. IsValue a => a -> Value
toValue a6
a6, forall a. IsValue a => a -> Value
toValue a7
a7, forall a. IsValue a => a -> Value
toValue a8
a8, forall a. IsValue a => a -> Value
toValue a9
a9, forall a. IsValue a => a -> Value
toValue a10
a10, forall a. IsValue a => a -> Value
toValue a11
a11, forall a. IsValue a => a -> Value
toValue a12
a12, forall a. IsValue a => a -> Value
toValue a13
a13, forall a. IsValue a => a -> Value
toValue a14
a14]
    fromValue :: Value
-> Maybe
     (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14)
fromValue (ValueStructure [Value
a1, Value
a2, Value
a3, Value
a4, Value
a5, Value
a6, Value
a7, Value
a8, Value
a9, Value
a10, Value
a11, Value
a12, Value
a13, Value
a14]) = do
        a1
a1' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a1
        a2
a2' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a2
        a3
a3' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a3
        a4
a4' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a4
        a5
a5' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a5
        a6
a6' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a6
        a7
a7' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a7
        a8
a8' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a8
        a9
a9' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a9
        a10
a10' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a10
        a11
a11' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a11
        a12
a12' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a12
        a13
a13' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a13
        a14
a14' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a14
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3', a4
a4', a5
a5', a6
a6', a7
a7', a8
a8', a9
a9', a10
a10', a11
a11', a12
a12', a13
a13', a14
a14')
    fromValue Value
_ = forall a. Maybe a
Nothing

instance (IsValue a1, IsValue a2, IsValue a3, IsValue a4, IsValue a5, IsValue a6, IsValue a7, IsValue a8, IsValue a9, IsValue a10, IsValue a11, IsValue a12, IsValue a13, IsValue a14, IsValue a15) => IsValue (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) where
    typeOf_ :: Proxy
  (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15)
-> Type
typeOf_ Proxy
  (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15)
_ = [Type] -> Type
TypeStructure
        [ forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a1)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a2)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a3)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a4)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a5)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a6)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a7)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a8)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a9)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a10)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a11)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a12)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a13)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a14)
        , forall a. IsValue a => Proxy a -> Type
typeOf_ (forall {k} (t :: k). Proxy t
Proxy :: Proxy a15)
        ]
    toValue :: (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15)
-> Value
toValue (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6, a7
a7, a8
a8, a9
a9, a10
a10, a11
a11, a12
a12, a13
a13, a14
a14, a15
a15) = [Value] -> Value
ValueStructure [forall a. IsValue a => a -> Value
toValue a1
a1, forall a. IsValue a => a -> Value
toValue a2
a2, forall a. IsValue a => a -> Value
toValue a3
a3, forall a. IsValue a => a -> Value
toValue a4
a4, forall a. IsValue a => a -> Value
toValue a5
a5, forall a. IsValue a => a -> Value
toValue a6
a6, forall a. IsValue a => a -> Value
toValue a7
a7, forall a. IsValue a => a -> Value
toValue a8
a8, forall a. IsValue a => a -> Value
toValue a9
a9, forall a. IsValue a => a -> Value
toValue a10
a10, forall a. IsValue a => a -> Value
toValue a11
a11, forall a. IsValue a => a -> Value
toValue a12
a12, forall a. IsValue a => a -> Value
toValue a13
a13, forall a. IsValue a => a -> Value
toValue a14
a14, forall a. IsValue a => a -> Value
toValue a15
a15]
    fromValue :: Value
-> Maybe
     (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15)
fromValue (ValueStructure [Value
a1, Value
a2, Value
a3, Value
a4, Value
a5, Value
a6, Value
a7, Value
a8, Value
a9, Value
a10, Value
a11, Value
a12, Value
a13, Value
a14, Value
a15]) = do
        a1
a1' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a1
        a2
a2' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a2
        a3
a3' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a3
        a4
a4' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a4
        a5
a5' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a5
        a6
a6' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a6
        a7
a7' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a7
        a8
a8' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a8
        a9
a9' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a9
        a10
a10' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a10
        a11
a11' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a11
        a12
a12' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a12
        a13
a13' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a13
        a14
a14' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a14
        a15
a15' <- forall a. IsValue a => Value -> Maybe a
fromValue Value
a15
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3', a4
a4', a5
a5', a6
a6', a7
a7', a8
a8', a9
a9', a10
a10', a11
a11', a12
a12', a13
a13', a14
a14', a15
a15')
    fromValue Value
_ = forall a. Maybe a
Nothing

instance (IsVariant a1, IsVariant a2, IsVariant a3) => IsVariant (a1, a2, a3) where
    toVariant :: (a1, a2, a3) -> Variant
toVariant (a1
a1, a2
a2, a3
a3) = Value -> Variant
Variant ([Value] -> Value
ValueStructure [forall a. IsVariant a => a -> Value
varToVal a1
a1, forall a. IsVariant a => a -> Value
varToVal a2
a2, forall a. IsVariant a => a -> Value
varToVal a3
a3])
    fromVariant :: Variant -> Maybe (a1, a2, a3)
fromVariant (Variant (ValueStructure [Value
a1, Value
a2, Value
a3])) = do
        a1
a1' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a1
        a2
a2' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a2
        a3
a3' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a3
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3')
    fromVariant Variant
_ = forall a. Maybe a
Nothing

instance (IsVariant a1, IsVariant a2, IsVariant a3, IsVariant a4) => IsVariant (a1, a2, a3, a4) where
    toVariant :: (a1, a2, a3, a4) -> Variant
toVariant (a1
a1, a2
a2, a3
a3, a4
a4) = Value -> Variant
Variant ([Value] -> Value
ValueStructure [forall a. IsVariant a => a -> Value
varToVal a1
a1, forall a. IsVariant a => a -> Value
varToVal a2
a2, forall a. IsVariant a => a -> Value
varToVal a3
a3, forall a. IsVariant a => a -> Value
varToVal a4
a4])
    fromVariant :: Variant -> Maybe (a1, a2, a3, a4)
fromVariant (Variant (ValueStructure [Value
a1, Value
a2, Value
a3, Value
a4])) = do
        a1
a1' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a1
        a2
a2' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a2
        a3
a3' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a3
        a4
a4' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a4
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3', a4
a4')
    fromVariant Variant
_ = forall a. Maybe a
Nothing

instance (IsVariant a1, IsVariant a2, IsVariant a3, IsVariant a4, IsVariant a5) => IsVariant (a1, a2, a3, a4, a5) where
    toVariant :: (a1, a2, a3, a4, a5) -> Variant
toVariant (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5) = Value -> Variant
Variant ([Value] -> Value
ValueStructure [forall a. IsVariant a => a -> Value
varToVal a1
a1, forall a. IsVariant a => a -> Value
varToVal a2
a2, forall a. IsVariant a => a -> Value
varToVal a3
a3, forall a. IsVariant a => a -> Value
varToVal a4
a4, forall a. IsVariant a => a -> Value
varToVal a5
a5])
    fromVariant :: Variant -> Maybe (a1, a2, a3, a4, a5)
fromVariant (Variant (ValueStructure [Value
a1, Value
a2, Value
a3, Value
a4, Value
a5])) = do
        a1
a1' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a1
        a2
a2' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a2
        a3
a3' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a3
        a4
a4' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a4
        a5
a5' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a5
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3', a4
a4', a5
a5')
    fromVariant Variant
_ = forall a. Maybe a
Nothing

instance (IsVariant a1, IsVariant a2, IsVariant a3, IsVariant a4, IsVariant a5, IsVariant a6) => IsVariant (a1, a2, a3, a4, a5, a6) where
    toVariant :: (a1, a2, a3, a4, a5, a6) -> Variant
toVariant (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6) = Value -> Variant
Variant ([Value] -> Value
ValueStructure [forall a. IsVariant a => a -> Value
varToVal a1
a1, forall a. IsVariant a => a -> Value
varToVal a2
a2, forall a. IsVariant a => a -> Value
varToVal a3
a3, forall a. IsVariant a => a -> Value
varToVal a4
a4, forall a. IsVariant a => a -> Value
varToVal a5
a5, forall a. IsVariant a => a -> Value
varToVal a6
a6])
    fromVariant :: Variant -> Maybe (a1, a2, a3, a4, a5, a6)
fromVariant (Variant (ValueStructure [Value
a1, Value
a2, Value
a3, Value
a4, Value
a5, Value
a6])) = do
        a1
a1' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a1
        a2
a2' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a2
        a3
a3' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a3
        a4
a4' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a4
        a5
a5' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a5
        a6
a6' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a6
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3', a4
a4', a5
a5', a6
a6')
    fromVariant Variant
_ = forall a. Maybe a
Nothing

instance (IsVariant a1, IsVariant a2, IsVariant a3, IsVariant a4, IsVariant a5, IsVariant a6, IsVariant a7) => IsVariant (a1, a2, a3, a4, a5, a6, a7) where
    toVariant :: (a1, a2, a3, a4, a5, a6, a7) -> Variant
toVariant (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6, a7
a7) = Value -> Variant
Variant ([Value] -> Value
ValueStructure [forall a. IsVariant a => a -> Value
varToVal a1
a1, forall a. IsVariant a => a -> Value
varToVal a2
a2, forall a. IsVariant a => a -> Value
varToVal a3
a3, forall a. IsVariant a => a -> Value
varToVal a4
a4, forall a. IsVariant a => a -> Value
varToVal a5
a5, forall a. IsVariant a => a -> Value
varToVal a6
a6, forall a. IsVariant a => a -> Value
varToVal a7
a7])
    fromVariant :: Variant -> Maybe (a1, a2, a3, a4, a5, a6, a7)
fromVariant (Variant (ValueStructure [Value
a1, Value
a2, Value
a3, Value
a4, Value
a5, Value
a6, Value
a7])) = do
        a1
a1' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a1
        a2
a2' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a2
        a3
a3' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a3
        a4
a4' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a4
        a5
a5' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a5
        a6
a6' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a6
        a7
a7' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a7
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3', a4
a4', a5
a5', a6
a6', a7
a7')
    fromVariant Variant
_ = forall a. Maybe a
Nothing

instance (IsVariant a1, IsVariant a2, IsVariant a3, IsVariant a4, IsVariant a5, IsVariant a6, IsVariant a7, IsVariant a8) => IsVariant (a1, a2, a3, a4, a5, a6, a7, a8) where
    toVariant :: (a1, a2, a3, a4, a5, a6, a7, a8) -> Variant
toVariant (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6, a7
a7, a8
a8) = Value -> Variant
Variant ([Value] -> Value
ValueStructure [forall a. IsVariant a => a -> Value
varToVal a1
a1, forall a. IsVariant a => a -> Value
varToVal a2
a2, forall a. IsVariant a => a -> Value
varToVal a3
a3, forall a. IsVariant a => a -> Value
varToVal a4
a4, forall a. IsVariant a => a -> Value
varToVal a5
a5, forall a. IsVariant a => a -> Value
varToVal a6
a6, forall a. IsVariant a => a -> Value
varToVal a7
a7, forall a. IsVariant a => a -> Value
varToVal a8
a8])
    fromVariant :: Variant -> Maybe (a1, a2, a3, a4, a5, a6, a7, a8)
fromVariant (Variant (ValueStructure [Value
a1, Value
a2, Value
a3, Value
a4, Value
a5, Value
a6, Value
a7, Value
a8])) = do
        a1
a1' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a1
        a2
a2' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a2
        a3
a3' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a3
        a4
a4' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a4
        a5
a5' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a5
        a6
a6' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a6
        a7
a7' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a7
        a8
a8' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a8
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3', a4
a4', a5
a5', a6
a6', a7
a7', a8
a8')
    fromVariant Variant
_ = forall a. Maybe a
Nothing

instance (IsVariant a1, IsVariant a2, IsVariant a3, IsVariant a4, IsVariant a5, IsVariant a6, IsVariant a7, IsVariant a8, IsVariant a9) => IsVariant (a1, a2, a3, a4, a5, a6, a7, a8, a9) where
    toVariant :: (a1, a2, a3, a4, a5, a6, a7, a8, a9) -> Variant
toVariant (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6, a7
a7, a8
a8, a9
a9) = Value -> Variant
Variant ([Value] -> Value
ValueStructure [forall a. IsVariant a => a -> Value
varToVal a1
a1, forall a. IsVariant a => a -> Value
varToVal a2
a2, forall a. IsVariant a => a -> Value
varToVal a3
a3, forall a. IsVariant a => a -> Value
varToVal a4
a4, forall a. IsVariant a => a -> Value
varToVal a5
a5, forall a. IsVariant a => a -> Value
varToVal a6
a6, forall a. IsVariant a => a -> Value
varToVal a7
a7, forall a. IsVariant a => a -> Value
varToVal a8
a8, forall a. IsVariant a => a -> Value
varToVal a9
a9])
    fromVariant :: Variant -> Maybe (a1, a2, a3, a4, a5, a6, a7, a8, a9)
fromVariant (Variant (ValueStructure [Value
a1, Value
a2, Value
a3, Value
a4, Value
a5, Value
a6, Value
a7, Value
a8, Value
a9])) = do
        a1
a1' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a1
        a2
a2' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a2
        a3
a3' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a3
        a4
a4' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a4
        a5
a5' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a5
        a6
a6' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a6
        a7
a7' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a7
        a8
a8' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a8
        a9
a9' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a9
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3', a4
a4', a5
a5', a6
a6', a7
a7', a8
a8', a9
a9')
    fromVariant Variant
_ = forall a. Maybe a
Nothing

instance (IsVariant a1, IsVariant a2, IsVariant a3, IsVariant a4, IsVariant a5, IsVariant a6, IsVariant a7, IsVariant a8, IsVariant a9, IsVariant a10) => IsVariant (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) where
    toVariant :: (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) -> Variant
toVariant (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6, a7
a7, a8
a8, a9
a9, a10
a10) = Value -> Variant
Variant ([Value] -> Value
ValueStructure [forall a. IsVariant a => a -> Value
varToVal a1
a1, forall a. IsVariant a => a -> Value
varToVal a2
a2, forall a. IsVariant a => a -> Value
varToVal a3
a3, forall a. IsVariant a => a -> Value
varToVal a4
a4, forall a. IsVariant a => a -> Value
varToVal a5
a5, forall a. IsVariant a => a -> Value
varToVal a6
a6, forall a. IsVariant a => a -> Value
varToVal a7
a7, forall a. IsVariant a => a -> Value
varToVal a8
a8, forall a. IsVariant a => a -> Value
varToVal a9
a9, forall a. IsVariant a => a -> Value
varToVal a10
a10])
    fromVariant :: Variant -> Maybe (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
fromVariant (Variant (ValueStructure [Value
a1, Value
a2, Value
a3, Value
a4, Value
a5, Value
a6, Value
a7, Value
a8, Value
a9, Value
a10])) = do
        a1
a1' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a1
        a2
a2' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a2
        a3
a3' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a3
        a4
a4' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a4
        a5
a5' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a5
        a6
a6' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a6
        a7
a7' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a7
        a8
a8' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a8
        a9
a9' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a9
        a10
a10' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a10
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3', a4
a4', a5
a5', a6
a6', a7
a7', a8
a8', a9
a9', a10
a10')
    fromVariant Variant
_ = forall a. Maybe a
Nothing

instance (IsVariant a1, IsVariant a2, IsVariant a3, IsVariant a4, IsVariant a5, IsVariant a6, IsVariant a7, IsVariant a8, IsVariant a9, IsVariant a10, IsVariant a11) => IsVariant (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) where
    toVariant :: (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) -> Variant
toVariant (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6, a7
a7, a8
a8, a9
a9, a10
a10, a11
a11) = Value -> Variant
Variant ([Value] -> Value
ValueStructure [forall a. IsVariant a => a -> Value
varToVal a1
a1, forall a. IsVariant a => a -> Value
varToVal a2
a2, forall a. IsVariant a => a -> Value
varToVal a3
a3, forall a. IsVariant a => a -> Value
varToVal a4
a4, forall a. IsVariant a => a -> Value
varToVal a5
a5, forall a. IsVariant a => a -> Value
varToVal a6
a6, forall a. IsVariant a => a -> Value
varToVal a7
a7, forall a. IsVariant a => a -> Value
varToVal a8
a8, forall a. IsVariant a => a -> Value
varToVal a9
a9, forall a. IsVariant a => a -> Value
varToVal a10
a10, forall a. IsVariant a => a -> Value
varToVal a11
a11])
    fromVariant :: Variant -> Maybe (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11)
fromVariant (Variant (ValueStructure [Value
a1, Value
a2, Value
a3, Value
a4, Value
a5, Value
a6, Value
a7, Value
a8, Value
a9, Value
a10, Value
a11])) = do
        a1
a1' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a1
        a2
a2' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a2
        a3
a3' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a3
        a4
a4' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a4
        a5
a5' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a5
        a6
a6' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a6
        a7
a7' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a7
        a8
a8' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a8
        a9
a9' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a9
        a10
a10' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a10
        a11
a11' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a11
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3', a4
a4', a5
a5', a6
a6', a7
a7', a8
a8', a9
a9', a10
a10', a11
a11')
    fromVariant Variant
_ = forall a. Maybe a
Nothing

instance (IsVariant a1, IsVariant a2, IsVariant a3, IsVariant a4, IsVariant a5, IsVariant a6, IsVariant a7, IsVariant a8, IsVariant a9, IsVariant a10, IsVariant a11, IsVariant a12) => IsVariant (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) where
    toVariant :: (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) -> Variant
toVariant (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6, a7
a7, a8
a8, a9
a9, a10
a10, a11
a11, a12
a12) = Value -> Variant
Variant ([Value] -> Value
ValueStructure [forall a. IsVariant a => a -> Value
varToVal a1
a1, forall a. IsVariant a => a -> Value
varToVal a2
a2, forall a. IsVariant a => a -> Value
varToVal a3
a3, forall a. IsVariant a => a -> Value
varToVal a4
a4, forall a. IsVariant a => a -> Value
varToVal a5
a5, forall a. IsVariant a => a -> Value
varToVal a6
a6, forall a. IsVariant a => a -> Value
varToVal a7
a7, forall a. IsVariant a => a -> Value
varToVal a8
a8, forall a. IsVariant a => a -> Value
varToVal a9
a9, forall a. IsVariant a => a -> Value
varToVal a10
a10, forall a. IsVariant a => a -> Value
varToVal a11
a11, forall a. IsVariant a => a -> Value
varToVal a12
a12])
    fromVariant :: Variant
-> Maybe (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12)
fromVariant (Variant (ValueStructure [Value
a1, Value
a2, Value
a3, Value
a4, Value
a5, Value
a6, Value
a7, Value
a8, Value
a9, Value
a10, Value
a11, Value
a12])) = do
        a1
a1' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a1
        a2
a2' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a2
        a3
a3' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a3
        a4
a4' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a4
        a5
a5' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a5
        a6
a6' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a6
        a7
a7' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a7
        a8
a8' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a8
        a9
a9' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a9
        a10
a10' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a10
        a11
a11' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a11
        a12
a12' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a12
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3', a4
a4', a5
a5', a6
a6', a7
a7', a8
a8', a9
a9', a10
a10', a11
a11', a12
a12')
    fromVariant Variant
_ = forall a. Maybe a
Nothing

instance (IsVariant a1, IsVariant a2, IsVariant a3, IsVariant a4, IsVariant a5, IsVariant a6, IsVariant a7, IsVariant a8, IsVariant a9, IsVariant a10, IsVariant a11, IsVariant a12, IsVariant a13) => IsVariant (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) where
    toVariant :: (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) -> Variant
toVariant (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6, a7
a7, a8
a8, a9
a9, a10
a10, a11
a11, a12
a12, a13
a13) = Value -> Variant
Variant ([Value] -> Value
ValueStructure [forall a. IsVariant a => a -> Value
varToVal a1
a1, forall a. IsVariant a => a -> Value
varToVal a2
a2, forall a. IsVariant a => a -> Value
varToVal a3
a3, forall a. IsVariant a => a -> Value
varToVal a4
a4, forall a. IsVariant a => a -> Value
varToVal a5
a5, forall a. IsVariant a => a -> Value
varToVal a6
a6, forall a. IsVariant a => a -> Value
varToVal a7
a7, forall a. IsVariant a => a -> Value
varToVal a8
a8, forall a. IsVariant a => a -> Value
varToVal a9
a9, forall a. IsVariant a => a -> Value
varToVal a10
a10, forall a. IsVariant a => a -> Value
varToVal a11
a11, forall a. IsVariant a => a -> Value
varToVal a12
a12, forall a. IsVariant a => a -> Value
varToVal a13
a13])
    fromVariant :: Variant
-> Maybe (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13)
fromVariant (Variant (ValueStructure [Value
a1, Value
a2, Value
a3, Value
a4, Value
a5, Value
a6, Value
a7, Value
a8, Value
a9, Value
a10, Value
a11, Value
a12, Value
a13])) = do
        a1
a1' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a1
        a2
a2' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a2
        a3
a3' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a3
        a4
a4' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a4
        a5
a5' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a5
        a6
a6' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a6
        a7
a7' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a7
        a8
a8' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a8
        a9
a9' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a9
        a10
a10' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a10
        a11
a11' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a11
        a12
a12' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a12
        a13
a13' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a13
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3', a4
a4', a5
a5', a6
a6', a7
a7', a8
a8', a9
a9', a10
a10', a11
a11', a12
a12', a13
a13')
    fromVariant Variant
_ = forall a. Maybe a
Nothing

instance (IsVariant a1, IsVariant a2, IsVariant a3, IsVariant a4, IsVariant a5, IsVariant a6, IsVariant a7, IsVariant a8, IsVariant a9, IsVariant a10, IsVariant a11, IsVariant a12, IsVariant a13, IsVariant a14) => IsVariant (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14) where
    toVariant :: (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14)
-> Variant
toVariant (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6, a7
a7, a8
a8, a9
a9, a10
a10, a11
a11, a12
a12, a13
a13, a14
a14) = Value -> Variant
Variant ([Value] -> Value
ValueStructure [forall a. IsVariant a => a -> Value
varToVal a1
a1, forall a. IsVariant a => a -> Value
varToVal a2
a2, forall a. IsVariant a => a -> Value
varToVal a3
a3, forall a. IsVariant a => a -> Value
varToVal a4
a4, forall a. IsVariant a => a -> Value
varToVal a5
a5, forall a. IsVariant a => a -> Value
varToVal a6
a6, forall a. IsVariant a => a -> Value
varToVal a7
a7, forall a. IsVariant a => a -> Value
varToVal a8
a8, forall a. IsVariant a => a -> Value
varToVal a9
a9, forall a. IsVariant a => a -> Value
varToVal a10
a10, forall a. IsVariant a => a -> Value
varToVal a11
a11, forall a. IsVariant a => a -> Value
varToVal a12
a12, forall a. IsVariant a => a -> Value
varToVal a13
a13, forall a. IsVariant a => a -> Value
varToVal a14
a14])
    fromVariant :: Variant
-> Maybe
     (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14)
fromVariant (Variant (ValueStructure [Value
a1, Value
a2, Value
a3, Value
a4, Value
a5, Value
a6, Value
a7, Value
a8, Value
a9, Value
a10, Value
a11, Value
a12, Value
a13, Value
a14])) = do
        a1
a1' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a1
        a2
a2' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a2
        a3
a3' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a3
        a4
a4' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a4
        a5
a5' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a5
        a6
a6' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a6
        a7
a7' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a7
        a8
a8' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a8
        a9
a9' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a9
        a10
a10' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a10
        a11
a11' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a11
        a12
a12' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a12
        a13
a13' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a13
        a14
a14' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a14
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3', a4
a4', a5
a5', a6
a6', a7
a7', a8
a8', a9
a9', a10
a10', a11
a11', a12
a12', a13
a13', a14
a14')
    fromVariant Variant
_ = forall a. Maybe a
Nothing

instance (IsVariant a1, IsVariant a2, IsVariant a3, IsVariant a4, IsVariant a5, IsVariant a6, IsVariant a7, IsVariant a8, IsVariant a9, IsVariant a10, IsVariant a11, IsVariant a12, IsVariant a13, IsVariant a14, IsVariant a15) => IsVariant (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) where
    toVariant :: (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15)
-> Variant
toVariant (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6, a7
a7, a8
a8, a9
a9, a10
a10, a11
a11, a12
a12, a13
a13, a14
a14, a15
a15) = Value -> Variant
Variant ([Value] -> Value
ValueStructure [forall a. IsVariant a => a -> Value
varToVal a1
a1, forall a. IsVariant a => a -> Value
varToVal a2
a2, forall a. IsVariant a => a -> Value
varToVal a3
a3, forall a. IsVariant a => a -> Value
varToVal a4
a4, forall a. IsVariant a => a -> Value
varToVal a5
a5, forall a. IsVariant a => a -> Value
varToVal a6
a6, forall a. IsVariant a => a -> Value
varToVal a7
a7, forall a. IsVariant a => a -> Value
varToVal a8
a8, forall a. IsVariant a => a -> Value
varToVal a9
a9, forall a. IsVariant a => a -> Value
varToVal a10
a10, forall a. IsVariant a => a -> Value
varToVal a11
a11, forall a. IsVariant a => a -> Value
varToVal a12
a12, forall a. IsVariant a => a -> Value
varToVal a13
a13, forall a. IsVariant a => a -> Value
varToVal a14
a14, forall a. IsVariant a => a -> Value
varToVal a15
a15])
    fromVariant :: Variant
-> Maybe
     (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15)
fromVariant (Variant (ValueStructure [Value
a1, Value
a2, Value
a3, Value
a4, Value
a5, Value
a6, Value
a7, Value
a8, Value
a9, Value
a10, Value
a11, Value
a12, Value
a13, Value
a14, Value
a15])) = do
        a1
a1' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a1
        a2
a2' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a2
        a3
a3' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a3
        a4
a4' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a4
        a5
a5' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a5
        a6
a6' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a6
        a7
a7' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a7
        a8
a8' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a8
        a9
a9' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a9
        a10
a10' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a10
        a11
a11' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a11
        a12
a12' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a12
        a13
a13' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a13
        a14
a14' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a14
        a15
a15' <- (forall a. IsVariant a => Variant -> Maybe a
fromVariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Variant
Variant) Value
a15
        forall (m :: * -> *) a. Monad m => a -> m a
return (a1
a1', a2
a2', a3
a3', a4
a4', a5
a5', a6
a6', a7
a7', a8
a8', a9
a9', a10
a10', a11
a11', a12
a12', a13
a13', a14
a14', a15
a15')
    fromVariant Variant
_ = forall a. Maybe a
Nothing

-- | A value used to uniquely identify a particular message within a session.
-- Serials are 32-bit unsigned integers, and eventually wrap.
newtype Serial = Serial Word32
    deriving (Serial -> Serial -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Serial -> Serial -> Bool
$c/= :: Serial -> Serial -> Bool
== :: Serial -> Serial -> Bool
$c== :: Serial -> Serial -> Bool
Eq, Eq Serial
Serial -> Serial -> Bool
Serial -> Serial -> Ordering
Serial -> Serial -> Serial
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Serial -> Serial -> Serial
$cmin :: Serial -> Serial -> Serial
max :: Serial -> Serial -> Serial
$cmax :: Serial -> Serial -> Serial
>= :: Serial -> Serial -> Bool
$c>= :: Serial -> Serial -> Bool
> :: Serial -> Serial -> Bool
$c> :: Serial -> Serial -> Bool
<= :: Serial -> Serial -> Bool
$c<= :: Serial -> Serial -> Bool
< :: Serial -> Serial -> Bool
$c< :: Serial -> Serial -> Bool
compare :: Serial -> Serial -> Ordering
$ccompare :: Serial -> Serial -> Ordering
Ord, Int -> Serial -> ShowS
[Serial] -> ShowS
Serial -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Serial] -> ShowS
$cshowList :: [Serial] -> ShowS
show :: Serial -> String
$cshow :: Serial -> String
showsPrec :: Int -> Serial -> ShowS
$cshowsPrec :: Int -> Serial -> ShowS
Show)

instance IsVariant Serial where
    toVariant :: Serial -> Variant
toVariant (Serial Word32
x) = forall a. IsVariant a => a -> Variant
toVariant Word32
x
    fromVariant :: Variant -> Maybe Serial
fromVariant = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Word32 -> Serial
Serial forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IsVariant a => Variant -> Maybe a
fromVariant

serialValue :: Serial -> Word32
serialValue :: Serial -> Word32
serialValue (Serial Word32
x) = Word32
x

-- | Get the first serial in the sequence.
firstSerial :: Serial
firstSerial :: Serial
firstSerial = Word32 -> Serial
Serial Word32
1

-- | Get the next serial in the sequence. This may wrap around to
-- 'firstSerial'.
nextSerial :: Serial -> Serial
nextSerial :: Serial -> Serial
nextSerial (Serial Word32
x) = Word32 -> Serial
Serial (if Word32
x forall a. Num a => a -> a -> a
+ Word32
1 forall a. Eq a => a -> a -> Bool
== Word32
0
    then Word32
1 -- wrap to firstSerial
    else Word32
x forall a. Num a => a -> a -> a
+ Word32
1)

skipSepBy1 :: Parsec.Parser a -> Parsec.Parser b -> Parsec.Parser ()
skipSepBy1 :: forall a b. Parser a -> Parser b -> Parser ()
skipSepBy1 Parser a
p Parser b
sep = do
    a
_ <- Parser a
p
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
Parsec.skipMany (Parser b
sep forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Parser a
p)

forceParse :: String -> (String -> Maybe a) -> String -> a
forceParse :: forall a. String -> (String -> Maybe a) -> String -> a
forceParse String
label String -> Maybe a
parse String
str = case String -> Maybe a
parse String
str of
    Just a
x -> a
x
    Maybe a
Nothing -> forall a. HasCallStack => String -> a
error (String
"Invalid " forall a. [a] -> [a] -> [a]
++ String
label forall a. [a] -> [a] -> [a]
++ String
": " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show String
str)

maybeParseString :: MonadThrow m => Parsec.Parser a -> String -> m a
maybeParseString :: forall (m :: * -> *) a. MonadThrow m => Parser a -> String -> m a
maybeParseString Parser a
parser String
s = case forall s t a.
Stream s Identity t =>
Parsec s () a -> String -> s -> Either ParseError a
Parsec.parse Parser a
parser String
"" String
s of
    Left ParseError
err -> forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM forall a b. (a -> b) -> a -> b
$ String -> IOError
userError forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> String
show ParseError
err
    Right a
a -> forall (f :: * -> *) a. Applicative f => a -> f a
pure a
a

THL.deriveLiftMany [''BusName, ''ObjectPath, ''InterfaceName, ''MemberName]