{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveTraversable #-}
module Codec.Candid.Types where
import qualified Data.ByteString.Lazy as BS
import qualified Data.Text as T
import qualified Data.Vector as V
import Data.Word
import Data.Int
import Numeric.Natural
import Control.Monad
import Data.Bifunctor
import Data.Void
import Data.Scientific
import Data.Char
import Numeric
import Prettyprinter
import Codec.Candid.Data
import Codec.Candid.FieldName
data Type a
= NatT | Nat8T | Nat16T | Nat32T | Nat64T
| IntT | Int8T | Int16T | Int32T | Int64T
| Float32T | Float64T
| BoolT
| TextT
| NullT
| ReservedT
| EmptyT
| OptT (Type a)
| VecT (Type a)
| RecT (Fields a)
| VariantT (Fields a)
| FuncT (MethodType a)
| ServiceT [(T.Text, MethodType a)]
| PrincipalT
| BlobT
| FutureT
| RefT a
deriving (Int -> Type a -> ShowS
forall a. Show a => Int -> Type a -> ShowS
forall a. Show a => [Type a] -> ShowS
forall a. Show a => Type a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Type a] -> ShowS
$cshowList :: forall a. Show a => [Type a] -> ShowS
show :: Type a -> String
$cshow :: forall a. Show a => Type a -> String
showsPrec :: Int -> Type a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Type a -> ShowS
Show, Type a -> Type a -> Bool
forall a. Eq a => Type a -> Type a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Type a -> Type a -> Bool
$c/= :: forall a. Eq a => Type a -> Type a -> Bool
== :: Type a -> Type a -> Bool
$c== :: forall a. Eq a => Type a -> Type a -> Bool
Eq, Type a -> Type a -> Ordering
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
forall {a}. Ord a => Eq (Type a)
forall a. Ord a => Type a -> Type a -> Bool
forall a. Ord a => Type a -> Type a -> Ordering
forall a. Ord a => Type a -> Type a -> Type a
min :: Type a -> Type a -> Type a
$cmin :: forall a. Ord a => Type a -> Type a -> Type a
max :: Type a -> Type a -> Type a
$cmax :: forall a. Ord a => Type a -> Type a -> Type a
>= :: Type a -> Type a -> Bool
$c>= :: forall a. Ord a => Type a -> Type a -> Bool
> :: Type a -> Type a -> Bool
$c> :: forall a. Ord a => Type a -> Type a -> Bool
<= :: Type a -> Type a -> Bool
$c<= :: forall a. Ord a => Type a -> Type a -> Bool
< :: Type a -> Type a -> Bool
$c< :: forall a. Ord a => Type a -> Type a -> Bool
compare :: Type a -> Type a -> Ordering
$ccompare :: forall a. Ord a => Type a -> Type a -> Ordering
Ord, forall a b. a -> Type b -> Type a
forall a b. (a -> b) -> Type a -> Type b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> Type b -> Type a
$c<$ :: forall a b. a -> Type b -> Type a
fmap :: forall a b. (a -> b) -> Type a -> Type b
$cfmap :: forall a b. (a -> b) -> Type a -> Type b
Functor, forall a. Eq a => a -> Type a -> Bool
forall a. Num a => Type a -> a
forall a. Ord a => Type a -> a
forall m. Monoid m => Type m -> m
forall a. Type a -> Bool
forall a. Type a -> Int
forall a. Type a -> [a]
forall a. (a -> a -> a) -> Type a -> a
forall m a. Monoid m => (a -> m) -> Type a -> m
forall b a. (b -> a -> b) -> b -> Type a -> b
forall a b. (a -> b -> b) -> b -> Type a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => Type a -> a
$cproduct :: forall a. Num a => Type a -> a
sum :: forall a. Num a => Type a -> a
$csum :: forall a. Num a => Type a -> a
minimum :: forall a. Ord a => Type a -> a
$cminimum :: forall a. Ord a => Type a -> a
maximum :: forall a. Ord a => Type a -> a
$cmaximum :: forall a. Ord a => Type a -> a
elem :: forall a. Eq a => a -> Type a -> Bool
$celem :: forall a. Eq a => a -> Type a -> Bool
length :: forall a. Type a -> Int
$clength :: forall a. Type a -> Int
null :: forall a. Type a -> Bool
$cnull :: forall a. Type a -> Bool
toList :: forall a. Type a -> [a]
$ctoList :: forall a. Type a -> [a]
foldl1 :: forall a. (a -> a -> a) -> Type a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Type a -> a
foldr1 :: forall a. (a -> a -> a) -> Type a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> Type a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> Type a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Type a -> b
foldl :: forall b a. (b -> a -> b) -> b -> Type a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Type a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> Type a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Type a -> b
foldr :: forall a b. (a -> b -> b) -> b -> Type a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> Type a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> Type a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Type a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> Type a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Type a -> m
fold :: forall m. Monoid m => Type m -> m
$cfold :: forall m. Monoid m => Type m -> m
Foldable, Functor Type
Foldable Type
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => Type (m a) -> m (Type a)
forall (f :: * -> *) a. Applicative f => Type (f a) -> f (Type a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Type a -> m (Type b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Type a -> f (Type b)
sequence :: forall (m :: * -> *) a. Monad m => Type (m a) -> m (Type a)
$csequence :: forall (m :: * -> *) a. Monad m => Type (m a) -> m (Type a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Type a -> m (Type b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Type a -> m (Type b)
sequenceA :: forall (f :: * -> *) a. Applicative f => Type (f a) -> f (Type a)
$csequenceA :: forall (f :: * -> *) a. Applicative f => Type (f a) -> f (Type a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Type a -> f (Type b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Type a -> f (Type b)
Traversable)
tupT :: [Type a] -> Type a
tupT :: forall a. [Type a] -> Type a
tupT = forall a. Fields a -> Type a
RecT forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith (\Word32
n Type a
t -> (Word32 -> FieldName
hashedField Word32
n, Type a
t)) [Word32
0..]
instance Applicative Type where
pure :: forall a. a -> Type a
pure = forall a. a -> Type a
RefT
<*> :: forall a b. Type (a -> b) -> Type a -> Type b
(<*>) = forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
ap
instance Monad Type where
return :: forall a. a -> Type a
return = forall (f :: * -> *) a. Applicative f => a -> f a
pure
Type a
NatT >>= :: forall a b. Type a -> (a -> Type b) -> Type b
>>= a -> Type b
_ = forall a. Type a
NatT
Type a
Nat8T >>= a -> Type b
_ = forall a. Type a
Nat8T
Type a
Nat16T >>= a -> Type b
_ = forall a. Type a
Nat16T
Type a
Nat32T >>= a -> Type b
_ = forall a. Type a
Nat32T
Type a
Nat64T >>= a -> Type b
_ = forall a. Type a
Nat64T
Type a
IntT >>= a -> Type b
_ = forall a. Type a
IntT
Type a
Int8T >>= a -> Type b
_ = forall a. Type a
Int8T
Type a
Int16T >>= a -> Type b
_ = forall a. Type a
Int16T
Type a
Int32T >>= a -> Type b
_ = forall a. Type a
Int32T
Type a
Int64T >>= a -> Type b
_ = forall a. Type a
Int64T
Type a
Float32T >>= a -> Type b
_ = forall a. Type a
Float32T
Type a
Float64T >>= a -> Type b
_ = forall a. Type a
Float64T
Type a
BoolT >>= a -> Type b
_ = forall a. Type a
BoolT
Type a
TextT >>= a -> Type b
_ = forall a. Type a
TextT
Type a
NullT >>= a -> Type b
_ = forall a. Type a
NullT
Type a
ReservedT >>= a -> Type b
_ = forall a. Type a
ReservedT
Type a
EmptyT >>= a -> Type b
_ = forall a. Type a
EmptyT
Type a
BlobT >>= a -> Type b
_ = forall a. Type a
BlobT
Type a
FutureT >>= a -> Type b
_ = forall a. Type a
FutureT
Type a
PrincipalT >>= a -> Type b
_ = forall a. Type a
PrincipalT
OptT Type a
t >>= a -> Type b
f = forall a. Type a -> Type a
OptT (Type a
t forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= a -> Type b
f)
VecT Type a
t >>= a -> Type b
f = forall a. Type a -> Type a
VecT (Type a
t forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= a -> Type b
f)
RecT Fields a
fs >>= a -> Type b
f = forall a. Fields a -> Type a
RecT (forall a b. (a -> b) -> [a] -> [b]
map (forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second (forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= a -> Type b
f)) Fields a
fs)
VariantT Fields a
fs >>= a -> Type b
f = forall a. Fields a -> Type a
VariantT (forall a b. (a -> b) -> [a] -> [b]
map (forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second (forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= a -> Type b
f)) Fields a
fs)
FuncT MethodType a
mt >>= a -> Type b
f = forall a. MethodType a -> Type a
FuncT (forall a b. (a -> Type b) -> MethodType a -> MethodType b
bindMethodType a -> Type b
f MethodType a
mt)
ServiceT [(Text, MethodType a)]
ms >>= a -> Type b
f = forall a. [(Text, MethodType a)] -> Type a
ServiceT (forall a b. (a -> b) -> [a] -> [b]
map (forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second (forall a b. (a -> Type b) -> MethodType a -> MethodType b
bindMethodType a -> Type b
f)) [(Text, MethodType a)]
ms)
RefT a
x >>= a -> Type b
f = a -> Type b
f a
x
bindMethodType :: (a -> Type b) -> MethodType a -> MethodType b
bindMethodType :: forall a b. (a -> Type b) -> MethodType a -> MethodType b
bindMethodType a -> Type b
f (MethodType [Type a]
as [Type a]
bs Bool
q Bool
ow) =
forall a. [Type a] -> [Type a] -> Bool -> Bool -> MethodType a
MethodType (forall a b. (a -> b) -> [a] -> [b]
map (forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= a -> Type b
f) [Type a]
as) (forall a b. (a -> b) -> [a] -> [b]
map (forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= a -> Type b
f) [Type a]
bs) Bool
q Bool
ow
type Fields a = [(FieldName, Type a)]
type Args a = [Type a]
instance Pretty a => Pretty (Type a) where
pretty :: forall ann. Type a -> Doc ann
pretty Type a
NatT = Doc ann
"nat"
pretty Type a
Nat8T = Doc ann
"nat8"
pretty Type a
Nat16T = Doc ann
"nat16"
pretty Type a
Nat32T = Doc ann
"nat32"
pretty Type a
Nat64T = Doc ann
"nat64"
pretty Type a
IntT = Doc ann
"int"
pretty Type a
Int8T = Doc ann
"int8"
pretty Type a
Int16T = Doc ann
"int16"
pretty Type a
Int32T = Doc ann
"int32"
pretty Type a
Int64T = Doc ann
"int64"
pretty Type a
Float32T = Doc ann
"float32"
pretty Type a
Float64T = Doc ann
"float64"
pretty Type a
BoolT = Doc ann
"bool"
pretty Type a
TextT = Doc ann
"text"
pretty Type a
NullT = Doc ann
"null"
pretty Type a
ReservedT = Doc ann
"reserved"
pretty Type a
EmptyT = Doc ann
"empty"
pretty (OptT Type a
t) = Doc ann
"opt" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => a -> Doc ann
pretty Type a
t
pretty (VecT Type a
t) = Doc ann
"vec" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => a -> Doc ann
pretty Type a
t
pretty (RecT Fields a
fs) = Doc ann
"record" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => Bool -> Fields a -> Doc ann
prettyFields Bool
False Fields a
fs
pretty (VariantT Fields a
fs) = Doc ann
"variant" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => Bool -> Fields a -> Doc ann
prettyFields Bool
True Fields a
fs
pretty (RefT a
a) = forall a ann. Pretty a => a -> Doc ann
pretty a
a
pretty Type a
BlobT = Doc ann
"blob"
pretty (FuncT MethodType a
mt) = Doc ann
"func" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => a -> Doc ann
pretty MethodType a
mt
pretty (ServiceT [(Text, MethodType a)]
s) =
Doc ann
"service" forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ann
":" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall ann. Doc ann -> Doc ann
braces (forall ann. Doc ann -> Doc ann
group (forall ann. Doc ann -> Doc ann
align (forall ann. [Doc ann] -> Doc ann
vsep forall a b. (a -> b) -> a -> b
$ forall a ann. Pretty a => (Text, MethodType a) -> Doc ann
prettyMeth forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Text, MethodType a)]
s)))
pretty Type a
PrincipalT = Doc ann
"principal"
pretty Type a
FutureT = Doc ann
"future"
prettyList :: forall ann. [Type a] -> Doc ann
prettyList = forall ann. Doc ann -> Doc ann -> Doc ann -> [Doc ann] -> Doc ann
encloseSep forall ann. Doc ann
lparen forall ann. Doc ann
rparen (forall ann. Doc ann
comma forall a. Semigroup a => a -> a -> a
<> forall ann. Doc ann
space) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map forall a ann. Pretty a => a -> Doc ann
pretty
prettyFields :: Pretty a => Bool -> Fields a -> Doc ann
prettyFields :: forall a ann. Pretty a => Bool -> Fields a -> Doc ann
prettyFields Bool
in_variant Fields a
fs = forall ann. [Doc ann] -> Doc ann
prettyBraceSemi forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map (forall a ann. Pretty a => Bool -> (FieldName, Type a) -> Doc ann
prettyField Bool
in_variant) Fields a
fs
prettyBraceSemi :: [Doc ann] -> Doc ann
prettyBraceSemi :: forall ann. [Doc ann] -> Doc ann
prettyBraceSemi = forall ann. Doc ann -> Doc ann
braces forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall ann. [Doc ann] -> Doc ann
hsep forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall ann. Doc ann -> [Doc ann] -> [Doc ann]
punctuate forall ann. Doc ann
semi
prettyField :: Pretty a => Bool -> (FieldName, Type a) -> Doc ann
prettyField :: forall a ann. Pretty a => Bool -> (FieldName, Type a) -> Doc ann
prettyField Bool
True (FieldName
f, Type a
NullT) = forall a ann. Pretty a => a -> Doc ann
pretty FieldName
f
prettyField Bool
_ (FieldName
f, Type a
t) = forall a ann. Pretty a => a -> Doc ann
pretty FieldName
f forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall ann. Doc ann
colon forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => a -> Doc ann
pretty Type a
t
data Value
= NumV Scientific
| NatV Natural
| Nat8V Word8
| Nat16V Word16
| Nat32V Word32
| Nat64V Word64
| IntV Integer
| Int8V Int8
| Int16V Int16
| Int32V Int32
| Int64V Int64
| Float32V Float
| Float64V Double
| BoolV Bool
| TextV T.Text
| NullV
| ReservedV
| OptV (Maybe Value)
| VecV (V.Vector Value)
| RecV [(FieldName, Value)]
| TupV [Value]
| VariantV FieldName Value
| FuncV Principal T.Text
| ServiceV Principal
| PrincipalV Principal
| BlobV BS.ByteString
| AnnV Value (Type Void)
| FutureV
deriving (Value -> Value -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Value -> Value -> Bool
$c/= :: Value -> Value -> Bool
== :: Value -> Value -> Bool
$c== :: Value -> Value -> Bool
Eq, Eq Value
Value -> Value -> Bool
Value -> Value -> Ordering
Value -> Value -> Value
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 :: Value -> Value -> Value
$cmin :: Value -> Value -> Value
max :: Value -> Value -> Value
$cmax :: Value -> Value -> Value
>= :: Value -> Value -> Bool
$c>= :: Value -> Value -> Bool
> :: Value -> Value -> Bool
$c> :: Value -> Value -> Bool
<= :: Value -> Value -> Bool
$c<= :: Value -> Value -> Bool
< :: Value -> Value -> Bool
$c< :: Value -> Value -> Bool
compare :: Value -> Value -> Ordering
$ccompare :: Value -> Value -> Ordering
Ord, 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)
instance Pretty Value where
pretty :: forall ann. Value -> Doc ann
pretty (NumV Scientific
v) = forall a ann. Pretty a => a -> Doc ann
pretty (forall a. Show a => a -> String
show Scientific
v)
pretty (NatV Natural
v) = forall a ann. Pretty a => a -> Doc ann
pretty Natural
v
pretty (IntV Integer
v) | Integer
v forall a. Ord a => a -> a -> Bool
>= Integer
0 = Doc ann
"+" forall a. Semigroup a => a -> a -> a
<> forall a ann. Pretty a => a -> Doc ann
pretty Integer
v
| Bool
otherwise = forall a ann. Pretty a => a -> Doc ann
pretty Integer
v
pretty (Nat8V Word8
v) = forall a ann. Pretty a => a -> Type Void -> Doc ann
prettyAnn Word8
v forall a. Type a
Nat8T
pretty (Nat16V Word16
v) = forall a ann. Pretty a => a -> Type Void -> Doc ann
prettyAnn Word16
v forall a. Type a
Nat16T
pretty (Nat32V Word32
v) = forall a ann. Pretty a => a -> Type Void -> Doc ann
prettyAnn Word32
v forall a. Type a
Nat32T
pretty (Nat64V Word64
v) = forall a ann. Pretty a => a -> Type Void -> Doc ann
prettyAnn Word64
v forall a. Type a
Nat64T
pretty (Int8V Int8
v) = forall a ann. Pretty a => a -> Type Void -> Doc ann
prettyAnn Int8
v forall a. Type a
Int8T
pretty (Int16V Int16
v) = forall a ann. Pretty a => a -> Type Void -> Doc ann
prettyAnn Int16
v forall a. Type a
Int16T
pretty (Int32V Int32
v) = forall a ann. Pretty a => a -> Type Void -> Doc ann
prettyAnn Int32
v forall a. Type a
Int32T
pretty (Int64V Int64
v) = forall a ann. Pretty a => a -> Type Void -> Doc ann
prettyAnn Int64
v forall a. Type a
Int64T
pretty (Float32V Float
v) = forall a ann. Pretty a => a -> Type Void -> Doc ann
prettyAnn Float
v forall a. Type a
Float32T
pretty (Float64V Double
v) = forall a ann. Pretty a => a -> Type Void -> Doc ann
prettyAnn Double
v forall a. Type a
Float64T
pretty (BoolV Bool
True) = Doc ann
"true"
pretty (BoolV Bool
False) = Doc ann
"false"
pretty (TextV Text
v) = forall ann. Text -> Doc ann
prettyText Text
v
pretty Value
NullV = Doc ann
"null"
pretty Value
ReservedV = forall a ann. Pretty a => a -> Type Void -> Doc ann
prettyAnn (Text
"null"::T.Text) forall a. Type a
ReservedT
pretty (FuncV Principal
b Text
m) = Doc ann
"func" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall ann. Text -> Doc ann
prettyText (Principal -> Text
prettyPrincipal Principal
b) forall a. Semigroup a => a -> a -> a
<> Doc ann
"." forall a. Semigroup a => a -> a -> a
<> forall ann. Text -> Doc ann
prettyText Text
m
pretty (ServiceV Principal
b) = Doc ann
"service" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall ann. Text -> Doc ann
prettyText (Principal -> Text
prettyPrincipal Principal
b)
pretty (PrincipalV Principal
b) = Doc ann
"principal" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall ann. Text -> Doc ann
prettyText (Principal -> Text
prettyPrincipal Principal
b)
pretty (BlobV ByteString
b) = Doc ann
"blob" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall ann. ByteString -> Doc ann
prettyBlob ByteString
b
pretty (OptV Maybe Value
Nothing) = forall a ann. Pretty a => a -> Doc ann
pretty Value
NullV
pretty (OptV (Just Value
v)) = Doc ann
"opt" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => a -> Doc ann
pretty Value
v
pretty (VecV Vector Value
vs) = Doc ann
"vec" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall ann. [Doc ann] -> Doc ann
prettyBraceSemi (forall a b. (a -> b) -> [a] -> [b]
map forall a ann. Pretty a => a -> Doc ann
pretty (forall a. Vector a -> [a]
V.toList Vector Value
vs))
pretty (TupV [Value]
vs) = Doc ann
"record" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall ann. [Doc ann] -> Doc ann
prettyBraceSemi (forall a b. (a -> b) -> [a] -> [b]
map forall a ann. Pretty a => a -> Doc ann
pretty [Value]
vs)
pretty (RecV [(FieldName, Value)]
vs) = Doc ann
"record" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall ann. [Doc ann] -> Doc ann
prettyBraceSemi (forall a b. (a -> b) -> [a] -> [b]
map forall {a} {a} {ann}. (Pretty a, Pretty a) => (a, a) -> Doc ann
go [(FieldName, Value)]
vs)
where go :: (a, a) -> Doc ann
go (a
fn, a
v) = forall a ann. Pretty a => a -> Doc ann
pretty a
fn forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ann
"=" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => a -> Doc ann
pretty a
v
pretty (VariantV FieldName
f Value
NullV) = Doc ann
"variant" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall ann. Doc ann -> Doc ann
braces (forall a ann. Pretty a => a -> Doc ann
pretty FieldName
f)
pretty (VariantV FieldName
f Value
v) = Doc ann
"variant" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall ann. Doc ann -> Doc ann
braces (forall a ann. Pretty a => a -> Doc ann
pretty FieldName
f forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ann
"=" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => a -> Doc ann
pretty Value
v)
pretty (AnnV Value
v Type Void
t) = forall a ann. Pretty a => a -> Type Void -> Doc ann
prettyAnn Value
v Type Void
t
pretty Value
FutureV = Doc ann
"future"
prettyList :: forall ann. [Value] -> Doc ann
prettyList = forall ann. Doc ann -> Doc ann -> Doc ann -> [Doc ann] -> Doc ann
encloseSep forall ann. Doc ann
lparen forall ann. Doc ann
rparen (forall ann. Doc ann
comma forall a. Semigroup a => a -> a -> a
<> forall ann. Doc ann
space) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map forall a ann. Pretty a => a -> Doc ann
pretty
prettyAnn :: Pretty a => a -> Type Void -> Doc ann
prettyAnn :: forall a ann. Pretty a => a -> Type Void -> Doc ann
prettyAnn a
v Type Void
t = forall ann. Doc ann -> Doc ann
parens forall a b. (a -> b) -> a -> b
$ forall a ann. Pretty a => a -> Doc ann
pretty a
v forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ann
":" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => a -> Doc ann
pretty Type Void
t
prettyBlob :: BS.ByteString -> Doc ann
prettyBlob :: forall ann. ByteString -> Doc ann
prettyBlob = forall ann. Doc ann -> Doc ann
dquotes forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a ann. Pretty a => a -> Doc ann
pretty forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Text] -> Text
T.concat forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map forall {a}. (Integral a, Show a) => a -> Text
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [Word8]
BS.unpack
where
go :: a -> Text
go a
b | forall a b. (Integral a, Num b) => a -> b
fromIntegral a
b forall a. Eq a => a -> a -> Bool
== Char -> Int
ord Char
'\t' = Text
"\\t"
go a
b | forall a b. (Integral a, Num b) => a -> b
fromIntegral a
b forall a. Eq a => a -> a -> Bool
== Char -> Int
ord Char
'\n' = Text
"\\n"
go a
b | forall a b. (Integral a, Num b) => a -> b
fromIntegral a
b forall a. Eq a => a -> a -> Bool
== Char -> Int
ord Char
'\r' = Text
"\\r"
go a
b | forall a b. (Integral a, Num b) => a -> b
fromIntegral a
b forall a. Eq a => a -> a -> Bool
== Char -> Int
ord Char
'"' = Text
"\\\""
go a
b | forall a b. (Integral a, Num b) => a -> b
fromIntegral a
b forall a. Eq a => a -> a -> Bool
== Char -> Int
ord Char
'\'' = Text
"\\\'"
go a
b | forall a b. (Integral a, Num b) => a -> b
fromIntegral a
b forall a. Eq a => a -> a -> Bool
== Char -> Int
ord Char
'\\' = Text
"\\\\"
go a
b | a
b forall a. Ord a => a -> a -> Bool
>= a
0x20 Bool -> Bool -> Bool
&& a
b forall a. Ord a => a -> a -> Bool
< a
0x7f = Char -> Text
T.singleton (Int -> Char
chr (forall a b. (Integral a, Num b) => a -> b
fromIntegral a
b))
go a
b | a
b forall a. Ord a => a -> a -> Bool
< a
0x10 = Text
"\\0" forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (forall a. (Integral a, Show a) => a -> ShowS
showHex a
b String
"")
go a
b = Text
"\\" forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (forall a. (Integral a, Show a) => a -> ShowS
showHex a
b String
"")
prettyText :: T.Text -> Doc ann
prettyText :: forall ann. Text -> Doc ann
prettyText = forall ann. Doc ann -> Doc ann
dquotes forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a ann. Pretty a => a -> Doc ann
pretty forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Text) -> Text -> Text
T.concatMap Char -> Text
go
where
go :: Char -> Text
go Char
'\t' = Text
"\\t"
go Char
'\n' = Text
"\\n"
go Char
'\r' = Text
"\\r"
go Char
'"' = Text
"\\\""
go Char
'\'' = Text
"\\\'"
go Char
'\\' = Text
"\\\\"
go Char
c | Char -> Bool
isControl Char
c = Text
"\\u{" forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (forall a. (Integral a, Show a) => a -> ShowS
showHex (Char -> Int
ord Char
c) String
"") forall a. Semigroup a => a -> a -> a
<> Text
"}"
go Char
c = Char -> Text
T.singleton Char
c
tupV :: [Value] -> Value
tupV :: [Value] -> Value
tupV = [(FieldName, Value)] -> Value
RecV forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith (\Word32
n Value
t -> (Word32 -> FieldName
hashedField Word32
n, Value
t)) [Word32
0..]
primTyp :: Integer -> Maybe (Type a)
primTyp :: forall a. Integer -> Maybe (Type a)
primTyp (-1) = forall a. a -> Maybe a
Just forall a. Type a
NullT
primTyp (-2) = forall a. a -> Maybe a
Just forall a. Type a
BoolT
primTyp (-3) = forall a. a -> Maybe a
Just forall a. Type a
NatT
primTyp (-4) = forall a. a -> Maybe a
Just forall a. Type a
IntT
primTyp (-5) = forall a. a -> Maybe a
Just forall a. Type a
Nat8T
primTyp (-6) = forall a. a -> Maybe a
Just forall a. Type a
Nat16T
primTyp (-7) = forall a. a -> Maybe a
Just forall a. Type a
Nat32T
primTyp (-8) = forall a. a -> Maybe a
Just forall a. Type a
Nat64T
primTyp (-9) = forall a. a -> Maybe a
Just forall a. Type a
Int8T
primTyp (-10) = forall a. a -> Maybe a
Just forall a. Type a
Int16T
primTyp (-11) = forall a. a -> Maybe a
Just forall a. Type a
Int32T
primTyp (-12) = forall a. a -> Maybe a
Just forall a. Type a
Int64T
primTyp (-13) = forall a. a -> Maybe a
Just forall a. Type a
Float32T
primTyp (-14) = forall a. a -> Maybe a
Just forall a. Type a
Float64T
primTyp (-15) = forall a. a -> Maybe a
Just forall a. Type a
TextT
primTyp (-16) = forall a. a -> Maybe a
Just forall a. Type a
ReservedT
primTyp (-17) = forall a. a -> Maybe a
Just forall a. Type a
EmptyT
primTyp (-24) = forall a. a -> Maybe a
Just forall a. Type a
PrincipalT
primTyp Integer
_ = forall a. Maybe a
Nothing
data MethodType a = MethodType
{ forall a. MethodType a -> [Type a]
methParams :: [Type a]
, forall a. MethodType a -> [Type a]
methResults :: [Type a]
, forall a. MethodType a -> Bool
methQuery :: Bool
, forall a. MethodType a -> Bool
methOneway :: Bool
}
deriving (MethodType a -> MethodType a -> Bool
forall a. Eq a => MethodType a -> MethodType a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MethodType a -> MethodType a -> Bool
$c/= :: forall a. Eq a => MethodType a -> MethodType a -> Bool
== :: MethodType a -> MethodType a -> Bool
$c== :: forall a. Eq a => MethodType a -> MethodType a -> Bool
Eq, MethodType a -> MethodType a -> Bool
MethodType a -> MethodType a -> Ordering
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
forall {a}. Ord a => Eq (MethodType a)
forall a. Ord a => MethodType a -> MethodType a -> Bool
forall a. Ord a => MethodType a -> MethodType a -> Ordering
forall a. Ord a => MethodType a -> MethodType a -> MethodType a
min :: MethodType a -> MethodType a -> MethodType a
$cmin :: forall a. Ord a => MethodType a -> MethodType a -> MethodType a
max :: MethodType a -> MethodType a -> MethodType a
$cmax :: forall a. Ord a => MethodType a -> MethodType a -> MethodType a
>= :: MethodType a -> MethodType a -> Bool
$c>= :: forall a. Ord a => MethodType a -> MethodType a -> Bool
> :: MethodType a -> MethodType a -> Bool
$c> :: forall a. Ord a => MethodType a -> MethodType a -> Bool
<= :: MethodType a -> MethodType a -> Bool
$c<= :: forall a. Ord a => MethodType a -> MethodType a -> Bool
< :: MethodType a -> MethodType a -> Bool
$c< :: forall a. Ord a => MethodType a -> MethodType a -> Bool
compare :: MethodType a -> MethodType a -> Ordering
$ccompare :: forall a. Ord a => MethodType a -> MethodType a -> Ordering
Ord, Int -> MethodType a -> ShowS
forall a. Show a => Int -> MethodType a -> ShowS
forall a. Show a => [MethodType a] -> ShowS
forall a. Show a => MethodType a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MethodType a] -> ShowS
$cshowList :: forall a. Show a => [MethodType a] -> ShowS
show :: MethodType a -> String
$cshow :: forall a. Show a => MethodType a -> String
showsPrec :: Int -> MethodType a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> MethodType a -> ShowS
Show, forall a b. a -> MethodType b -> MethodType a
forall a b. (a -> b) -> MethodType a -> MethodType b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> MethodType b -> MethodType a
$c<$ :: forall a b. a -> MethodType b -> MethodType a
fmap :: forall a b. (a -> b) -> MethodType a -> MethodType b
$cfmap :: forall a b. (a -> b) -> MethodType a -> MethodType b
Functor, forall a. Eq a => a -> MethodType a -> Bool
forall a. Num a => MethodType a -> a
forall a. Ord a => MethodType a -> a
forall m. Monoid m => MethodType m -> m
forall a. MethodType a -> Bool
forall a. MethodType a -> Int
forall a. MethodType a -> [a]
forall a. (a -> a -> a) -> MethodType a -> a
forall m a. Monoid m => (a -> m) -> MethodType a -> m
forall b a. (b -> a -> b) -> b -> MethodType a -> b
forall a b. (a -> b -> b) -> b -> MethodType a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => MethodType a -> a
$cproduct :: forall a. Num a => MethodType a -> a
sum :: forall a. Num a => MethodType a -> a
$csum :: forall a. Num a => MethodType a -> a
minimum :: forall a. Ord a => MethodType a -> a
$cminimum :: forall a. Ord a => MethodType a -> a
maximum :: forall a. Ord a => MethodType a -> a
$cmaximum :: forall a. Ord a => MethodType a -> a
elem :: forall a. Eq a => a -> MethodType a -> Bool
$celem :: forall a. Eq a => a -> MethodType a -> Bool
length :: forall a. MethodType a -> Int
$clength :: forall a. MethodType a -> Int
null :: forall a. MethodType a -> Bool
$cnull :: forall a. MethodType a -> Bool
toList :: forall a. MethodType a -> [a]
$ctoList :: forall a. MethodType a -> [a]
foldl1 :: forall a. (a -> a -> a) -> MethodType a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> MethodType a -> a
foldr1 :: forall a. (a -> a -> a) -> MethodType a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> MethodType a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> MethodType a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> MethodType a -> b
foldl :: forall b a. (b -> a -> b) -> b -> MethodType a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> MethodType a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> MethodType a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> MethodType a -> b
foldr :: forall a b. (a -> b -> b) -> b -> MethodType a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> MethodType a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> MethodType a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> MethodType a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> MethodType a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> MethodType a -> m
fold :: forall m. Monoid m => MethodType m -> m
$cfold :: forall m. Monoid m => MethodType m -> m
Foldable, Functor MethodType
Foldable MethodType
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
MethodType (m a) -> m (MethodType a)
forall (f :: * -> *) a.
Applicative f =>
MethodType (f a) -> f (MethodType a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> MethodType a -> m (MethodType b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> MethodType a -> f (MethodType b)
sequence :: forall (m :: * -> *) a.
Monad m =>
MethodType (m a) -> m (MethodType a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
MethodType (m a) -> m (MethodType a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> MethodType a -> m (MethodType b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> MethodType a -> m (MethodType b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
MethodType (f a) -> f (MethodType a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
MethodType (f a) -> f (MethodType a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> MethodType a -> f (MethodType b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> MethodType a -> f (MethodType b)
Traversable)
type TypeName = T.Text
type DidService a = [(T.Text, MethodType a)]
type DidDef a = (a, Type a)
data DidFile = DidFile
{ DidFile -> [DidDef Text]
defs :: [ DidDef TypeName ]
, DidFile -> DidService Text
service :: DidService TypeName
}
deriving (DidFile -> DidFile -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DidFile -> DidFile -> Bool
$c/= :: DidFile -> DidFile -> Bool
== :: DidFile -> DidFile -> Bool
$c== :: DidFile -> DidFile -> Bool
Eq, Int -> DidFile -> ShowS
[DidFile] -> ShowS
DidFile -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DidFile] -> ShowS
$cshowList :: [DidFile] -> ShowS
show :: DidFile -> String
$cshow :: DidFile -> String
showsPrec :: Int -> DidFile -> ShowS
$cshowsPrec :: Int -> DidFile -> ShowS
Show)
instance Pretty a => Pretty (MethodType a) where
pretty :: forall ann. MethodType a -> Doc ann
pretty (MethodType [Type a]
params [Type a]
results Bool
q Bool
o) = forall ann. [Doc ann] -> Doc ann
sep forall a b. (a -> b) -> a -> b
$
[ forall a ann. Pretty a => a -> Doc ann
pretty [Type a]
params
, Doc ann
"->"
, forall a ann. Pretty a => a -> Doc ann
pretty [Type a]
results
] forall a. Semigroup a => a -> a -> a
<>
[ Doc ann
"query" | Bool
q ] forall a. Semigroup a => a -> a -> a
<>
[ Doc ann
"oneway" | Bool
o ]
prettyDef :: Pretty a => DidDef a -> Doc ann
prettyDef :: forall a ann. Pretty a => DidDef a -> Doc ann
prettyDef (a
tn, Type a
t) = Doc ann
"type" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => a -> Doc ann
pretty a
tn forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ann
"=" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => a -> Doc ann
pretty Type a
t forall a. Semigroup a => a -> a -> a
<> forall ann. Doc ann
semi
prettyMeth :: Pretty a => (T.Text, MethodType a) -> Doc ann
prettyMeth :: forall a ann. Pretty a => (Text, MethodType a) -> Doc ann
prettyMeth (Text
n, MethodType a
t) = forall a ann. Pretty a => a -> Doc ann
pretty Text
n forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall ann. Doc ann
colon forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => a -> Doc ann
pretty MethodType a
t forall a. Semigroup a => a -> a -> a
<> forall ann. Doc ann
semi
instance Pretty DidFile where
pretty :: forall ann. DidFile -> Doc ann
pretty (DidFile [DidDef Text]
defs DidService Text
s) = forall ann. [Doc ann] -> Doc ann
vsep forall a b. (a -> b) -> a -> b
$
(forall a ann. Pretty a => DidDef a -> Doc ann
prettyDef forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [DidDef Text]
defs) forall a. [a] -> [a] -> [a]
++
[ Doc ann
"service" forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ann
":" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall ann. Doc ann -> Doc ann
braces (forall ann. Doc ann -> Doc ann
group (forall ann. Doc ann -> Doc ann
align (forall ann. [Doc ann] -> Doc ann
vsep forall a b. (a -> b) -> a -> b
$ forall a ann. Pretty a => (Text, MethodType a) -> Doc ann
prettyMeth forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DidService Text
s))) ]