{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Data.Morpheus.Types.GQLWrapper
( EncodeWrapper (..),
DecodeWrapper (..),
DecodeWrapperConstraint,
EncodeWrapperValue (..),
)
where
import qualified Data.List.NonEmpty as NonEmpty
import Data.Morpheus.App.Internal.Resolving
( ResolverValue,
SubscriptionField (..),
mkList,
mkNull,
)
import Data.Morpheus.Types.Internal.AST
( CONST,
GQLError,
ValidValue,
Value (..),
msg,
)
import qualified Data.Sequence as Seq
import qualified Data.Set as Set
import Data.Vector (Vector)
import qualified Data.Vector as Vector
import Relude
class EncodeWrapper (wrapper :: Type -> Type) where
encodeWrapper ::
(Monad m) =>
(a -> m (ResolverValue m)) ->
wrapper a ->
m (ResolverValue m)
withList :: (Monad m, Foldable f) => (a -> m (ResolverValue m)) -> f a -> m (ResolverValue m)
withList :: forall (m :: * -> *) (f :: * -> *) a.
(Monad m, Foldable f) =>
(a -> m (ResolverValue m)) -> f a -> m (ResolverValue m)
withList a -> m (ResolverValue m)
encodeValue = (a -> m (ResolverValue m)) -> [a] -> m (ResolverValue m)
forall (wrapper :: * -> *) (m :: * -> *) a.
(EncodeWrapper wrapper, Monad m) =>
(a -> m (ResolverValue m)) -> wrapper a -> m (ResolverValue m)
forall (m :: * -> *) a.
Monad m =>
(a -> m (ResolverValue m)) -> [a] -> m (ResolverValue m)
encodeWrapper a -> m (ResolverValue m)
encodeValue ([a] -> m (ResolverValue m))
-> (f a -> [a]) -> f a -> m (ResolverValue m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f a -> [a]
forall a. f a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList
instance EncodeWrapper Maybe where
encodeWrapper :: forall (m :: * -> *) a.
Monad m =>
(a -> m (ResolverValue m)) -> Maybe a -> m (ResolverValue m)
encodeWrapper = m (ResolverValue m)
-> (a -> m (ResolverValue m)) -> Maybe a -> m (ResolverValue m)
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (ResolverValue m -> m (ResolverValue m)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ResolverValue m
forall (m :: * -> *). ResolverValue m
mkNull)
instance EncodeWrapper [] where
encodeWrapper :: forall (m :: * -> *) a.
Monad m =>
(a -> m (ResolverValue m)) -> [a] -> m (ResolverValue m)
encodeWrapper a -> m (ResolverValue m)
encodeValue = ([ResolverValue m] -> ResolverValue m)
-> m [ResolverValue m] -> m (ResolverValue m)
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [ResolverValue m] -> ResolverValue m
forall (m :: * -> *). [ResolverValue m] -> ResolverValue m
mkList (m [ResolverValue m] -> m (ResolverValue m))
-> ([a] -> m [ResolverValue m]) -> [a] -> m (ResolverValue m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> m (ResolverValue m)) -> [a] -> m [ResolverValue m]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse a -> m (ResolverValue m)
encodeValue
instance EncodeWrapper NonEmpty where
encodeWrapper :: forall (m :: * -> *) a.
Monad m =>
(a -> m (ResolverValue m)) -> NonEmpty a -> m (ResolverValue m)
encodeWrapper = (a -> m (ResolverValue m)) -> NonEmpty a -> m (ResolverValue m)
forall (m :: * -> *) (f :: * -> *) a.
(Monad m, Foldable f) =>
(a -> m (ResolverValue m)) -> f a -> m (ResolverValue m)
withList
instance EncodeWrapper Seq where
encodeWrapper :: forall (m :: * -> *) a.
Monad m =>
(a -> m (ResolverValue m)) -> Seq a -> m (ResolverValue m)
encodeWrapper = (a -> m (ResolverValue m)) -> Seq a -> m (ResolverValue m)
forall (m :: * -> *) (f :: * -> *) a.
(Monad m, Foldable f) =>
(a -> m (ResolverValue m)) -> f a -> m (ResolverValue m)
withList
instance EncodeWrapper Vector where
encodeWrapper :: forall (m :: * -> *) a.
Monad m =>
(a -> m (ResolverValue m)) -> Vector a -> m (ResolverValue m)
encodeWrapper = (a -> m (ResolverValue m)) -> Vector a -> m (ResolverValue m)
forall (m :: * -> *) (f :: * -> *) a.
(Monad m, Foldable f) =>
(a -> m (ResolverValue m)) -> f a -> m (ResolverValue m)
withList
instance EncodeWrapper Set where
encodeWrapper :: forall (m :: * -> *) a.
Monad m =>
(a -> m (ResolverValue m)) -> Set a -> m (ResolverValue m)
encodeWrapper = (a -> m (ResolverValue m)) -> Set a -> m (ResolverValue m)
forall (m :: * -> *) (f :: * -> *) a.
(Monad m, Foldable f) =>
(a -> m (ResolverValue m)) -> f a -> m (ResolverValue m)
withList
instance EncodeWrapper SubscriptionField where
encodeWrapper :: forall (m :: * -> *) a.
Monad m =>
(a -> m (ResolverValue m))
-> SubscriptionField a -> m (ResolverValue m)
encodeWrapper a -> m (ResolverValue m)
encode (SubscriptionField forall (m :: * -> *) v.
(a ~ m v, MonadResolver m, MonadOperation m ~ SUBSCRIPTION) =>
Channel (MonadEvent m)
_ a
res) = a -> m (ResolverValue m)
encode a
res
type family DecodeWrapperConstraint (f :: Type -> Type) a :: Constraint where
DecodeWrapperConstraint Set a = (Ord a)
DecodeWrapperConstraint f a = ()
class DecodeWrapper (f :: Type -> Type) where
decodeWrapper ::
(Monad m, DecodeWrapperConstraint f a) =>
(ValidValue -> m a) ->
ValidValue ->
ExceptT GQLError m (f a)
instance DecodeWrapper Maybe where
decodeWrapper :: forall (m :: * -> *) a.
(Monad m, DecodeWrapperConstraint Maybe a) =>
(ValidValue -> m a) -> ValidValue -> ExceptT GQLError m (Maybe a)
decodeWrapper ValidValue -> m a
_ ValidValue
Null = Maybe a -> ExceptT GQLError m (Maybe a)
forall a. a -> ExceptT GQLError m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe a
forall a. Maybe a
Nothing
decodeWrapper ValidValue -> m a
decode ValidValue
x = a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a)
-> ExceptT GQLError m a -> ExceptT GQLError m (Maybe a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m a -> ExceptT GQLError m a
forall (m :: * -> *) a. Monad m => m a -> ExceptT GQLError m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (ValidValue -> m a
decode ValidValue
x)
instance DecodeWrapper [] where
decodeWrapper :: forall (m :: * -> *) a.
(Monad m, DecodeWrapperConstraint [] a) =>
(ValidValue -> m a) -> ValidValue -> ExceptT GQLError m [a]
decodeWrapper ValidValue -> m a
decode (List [ValidValue]
li) = m [a] -> ExceptT GQLError m [a]
forall (m :: * -> *) a. Monad m => m a -> ExceptT GQLError m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m [a] -> ExceptT GQLError m [a])
-> m [a] -> ExceptT GQLError m [a]
forall a b. (a -> b) -> a -> b
$ (ValidValue -> m a) -> [ValidValue] -> m [a]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse ValidValue -> m a
decode [ValidValue]
li
decodeWrapper ValidValue -> m a
_ ValidValue
isType = m (Either GQLError [a]) -> ExceptT GQLError m [a]
forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
ExceptT (m (Either GQLError [a]) -> ExceptT GQLError m [a])
-> m (Either GQLError [a]) -> ExceptT GQLError m [a]
forall a b. (a -> b) -> a -> b
$ Either GQLError [a] -> m (Either GQLError [a])
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either GQLError [a] -> m (Either GQLError [a]))
-> Either GQLError [a] -> m (Either GQLError [a])
forall a b. (a -> b) -> a -> b
$ GQLError -> Either GQLError [a]
forall a b. a -> Either a b
Left (GQLError -> ValidValue -> GQLError
forall (s :: Stage). GQLError -> Value s -> GQLError
typeMismatch GQLError
"List" ValidValue
isType)
instance DecodeWrapper NonEmpty where
decodeWrapper :: forall (m :: * -> *) a.
(Monad m, DecodeWrapperConstraint NonEmpty a) =>
(ValidValue -> m a)
-> ValidValue -> ExceptT GQLError m (NonEmpty a)
decodeWrapper = ([a] -> Either GQLError (NonEmpty a))
-> (ValidValue -> m a)
-> ValidValue
-> ExceptT GQLError m (NonEmpty a)
forall (m :: * -> *) a (rList :: * -> *).
Monad m =>
([a] -> Either GQLError (rList a))
-> (ValidValue -> m a)
-> ValidValue
-> ExceptT GQLError m (rList a)
withRefinedList (Either GQLError (NonEmpty a)
-> (NonEmpty a -> Either GQLError (NonEmpty a))
-> Maybe (NonEmpty a)
-> Either GQLError (NonEmpty a)
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (GQLError -> Either GQLError (NonEmpty a)
forall a b. a -> Either a b
Left GQLError
"Expected a NonEmpty list") NonEmpty a -> Either GQLError (NonEmpty a)
forall a b. b -> Either a b
Right (Maybe (NonEmpty a) -> Either GQLError (NonEmpty a))
-> ([a] -> Maybe (NonEmpty a))
-> [a]
-> Either GQLError (NonEmpty a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [a] -> Maybe (NonEmpty a)
forall a. [a] -> Maybe (NonEmpty a)
NonEmpty.nonEmpty)
instance DecodeWrapper Seq where
decodeWrapper :: forall (m :: * -> *) a.
(Monad m, DecodeWrapperConstraint Seq a) =>
(ValidValue -> m a) -> ValidValue -> ExceptT GQLError m (Seq a)
decodeWrapper ValidValue -> m a
decode = ([a] -> Seq a)
-> ExceptT GQLError m [a] -> ExceptT GQLError m (Seq a)
forall a b.
(a -> b) -> ExceptT GQLError m a -> ExceptT GQLError m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [a] -> Seq a
forall a. [a] -> Seq a
Seq.fromList (ExceptT GQLError m [a] -> ExceptT GQLError m (Seq a))
-> (ValidValue -> ExceptT GQLError m [a])
-> ValidValue
-> ExceptT GQLError m (Seq a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ValidValue -> m a) -> ValidValue -> ExceptT GQLError m [a]
forall (f :: * -> *) (m :: * -> *) a.
(DecodeWrapper f, Monad m, DecodeWrapperConstraint f a) =>
(ValidValue -> m a) -> ValidValue -> ExceptT GQLError m (f a)
forall (m :: * -> *) a.
(Monad m, DecodeWrapperConstraint [] a) =>
(ValidValue -> m a) -> ValidValue -> ExceptT GQLError m [a]
decodeWrapper ValidValue -> m a
decode
instance DecodeWrapper Vector where
decodeWrapper :: forall (m :: * -> *) a.
(Monad m, DecodeWrapperConstraint Vector a) =>
(ValidValue -> m a) -> ValidValue -> ExceptT GQLError m (Vector a)
decodeWrapper ValidValue -> m a
decode = ([a] -> Vector a)
-> ExceptT GQLError m [a] -> ExceptT GQLError m (Vector a)
forall a b.
(a -> b) -> ExceptT GQLError m a -> ExceptT GQLError m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [a] -> Vector a
forall a. [a] -> Vector a
Vector.fromList (ExceptT GQLError m [a] -> ExceptT GQLError m (Vector a))
-> (ValidValue -> ExceptT GQLError m [a])
-> ValidValue
-> ExceptT GQLError m (Vector a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ValidValue -> m a) -> ValidValue -> ExceptT GQLError m [a]
forall (f :: * -> *) (m :: * -> *) a.
(DecodeWrapper f, Monad m, DecodeWrapperConstraint f a) =>
(ValidValue -> m a) -> ValidValue -> ExceptT GQLError m (f a)
forall (m :: * -> *) a.
(Monad m, DecodeWrapperConstraint [] a) =>
(ValidValue -> m a) -> ValidValue -> ExceptT GQLError m [a]
decodeWrapper ValidValue -> m a
decode
instance DecodeWrapper Set where
decodeWrapper :: forall (m :: * -> *) a.
(Monad m, DecodeWrapperConstraint Set a) =>
(ValidValue -> m a) -> ValidValue -> ExceptT GQLError m (Set a)
decodeWrapper ValidValue -> m a
decode ValidValue
value = do
[a]
listVal <- (ValidValue -> m a) -> ValidValue -> ExceptT GQLError m [a]
forall (f :: * -> *) (m :: * -> *) a.
(DecodeWrapper f, Monad m, DecodeWrapperConstraint f a) =>
(ValidValue -> m a) -> ValidValue -> ExceptT GQLError m (f a)
forall (m :: * -> *) a.
(Monad m, DecodeWrapperConstraint [] a) =>
(ValidValue -> m a) -> ValidValue -> ExceptT GQLError m [a]
decodeWrapper ValidValue -> m a
decode ValidValue
value
Set a -> [a] -> ExceptT GQLError m (Set a)
forall (l :: * -> *) (m :: * -> *) a b.
(Foldable l, Monad m) =>
Set a -> l b -> ExceptT GQLError m (Set a)
haveSameSize ([a] -> Set a
forall a. Ord a => [a] -> Set a
Set.fromList [a]
listVal) [a]
listVal
haveSameSize ::
( Foldable l,
Monad m
) =>
Set a ->
l b ->
ExceptT GQLError m (Set a)
haveSameSize :: forall (l :: * -> *) (m :: * -> *) a b.
(Foldable l, Monad m) =>
Set a -> l b -> ExceptT GQLError m (Set a)
haveSameSize Set a
setVal l b
listVal
| Set a -> Int
forall a. Set a -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length Set a
setVal Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== l b -> Int
forall a. l a -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length l b
listVal = Set a -> ExceptT GQLError m (Set a)
forall a. a -> ExceptT GQLError m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Set a
setVal
| Bool
otherwise = m (Either GQLError (Set a)) -> ExceptT GQLError m (Set a)
forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
ExceptT (m (Either GQLError (Set a)) -> ExceptT GQLError m (Set a))
-> m (Either GQLError (Set a)) -> ExceptT GQLError m (Set a)
forall a b. (a -> b) -> a -> b
$ Either GQLError (Set a) -> m (Either GQLError (Set a))
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either GQLError (Set a) -> m (Either GQLError (Set a)))
-> Either GQLError (Set a) -> m (Either GQLError (Set a))
forall a b. (a -> b) -> a -> b
$ GQLError -> Either GQLError (Set a)
forall a b. a -> Either a b
Left (String -> GQLError
forall a. IsString a => String -> a
fromString (String
"Expected a List without duplicates, found " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall b a. (Show a, IsString b) => a -> b
show (l b -> Int
forall a. l a -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length l b
listVal Int -> Int -> Int
forall a. Num a => a -> a -> a
- Set a -> Int
forall a. Set a -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length Set a
setVal) String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" duplicates"))
withRefinedList ::
Monad m =>
([a] -> Either GQLError (rList a)) ->
(ValidValue -> m a) ->
ValidValue ->
ExceptT GQLError m (rList a)
withRefinedList :: forall (m :: * -> *) a (rList :: * -> *).
Monad m =>
([a] -> Either GQLError (rList a))
-> (ValidValue -> m a)
-> ValidValue
-> ExceptT GQLError m (rList a)
withRefinedList [a] -> Either GQLError (rList a)
refiner ValidValue -> m a
decode (List [ValidValue]
li) = do
[a]
listRes <- m [a] -> ExceptT GQLError m [a]
forall (m :: * -> *) a. Monad m => m a -> ExceptT GQLError m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((ValidValue -> m a) -> [ValidValue] -> m [a]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse ValidValue -> m a
decode [ValidValue]
li)
case [a] -> Either GQLError (rList a)
refiner [a]
listRes of
Left GQLError
err -> m (Either GQLError (rList a)) -> ExceptT GQLError m (rList a)
forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
ExceptT (m (Either GQLError (rList a)) -> ExceptT GQLError m (rList a))
-> m (Either GQLError (rList a)) -> ExceptT GQLError m (rList a)
forall a b. (a -> b) -> a -> b
$ Either GQLError (rList a) -> m (Either GQLError (rList a))
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either GQLError (rList a) -> m (Either GQLError (rList a)))
-> Either GQLError (rList a) -> m (Either GQLError (rList a))
forall a b. (a -> b) -> a -> b
$ GQLError -> Either GQLError (rList a)
forall a b. a -> Either a b
Left (GQLError -> ValidValue -> GQLError
forall (s :: Stage). GQLError -> Value s -> GQLError
typeMismatch GQLError
err ([ValidValue] -> ValidValue
forall (stage :: Stage). [Value stage] -> Value stage
List [ValidValue]
li))
Right rList a
value -> rList a -> ExceptT GQLError m (rList a)
forall a. a -> ExceptT GQLError m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure rList a
value
withRefinedList [a] -> Either GQLError (rList a)
_ ValidValue -> m a
_ ValidValue
isType = m (Either GQLError (rList a)) -> ExceptT GQLError m (rList a)
forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
ExceptT (m (Either GQLError (rList a)) -> ExceptT GQLError m (rList a))
-> m (Either GQLError (rList a)) -> ExceptT GQLError m (rList a)
forall a b. (a -> b) -> a -> b
$ Either GQLError (rList a) -> m (Either GQLError (rList a))
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either GQLError (rList a) -> m (Either GQLError (rList a)))
-> Either GQLError (rList a) -> m (Either GQLError (rList a))
forall a b. (a -> b) -> a -> b
$ GQLError -> Either GQLError (rList a)
forall a b. a -> Either a b
Left (GQLError -> ValidValue -> GQLError
forall (s :: Stage). GQLError -> Value s -> GQLError
typeMismatch GQLError
"List" ValidValue
isType)
typeMismatch :: GQLError -> Value s -> GQLError
typeMismatch :: forall (s :: Stage). GQLError -> Value s -> GQLError
typeMismatch GQLError
text Value s
jsType =
GQLError
"Type mismatch! expected:"
GQLError -> GQLError -> GQLError
forall a. Semigroup a => a -> a -> a
<> GQLError -> GQLError
forall a. Msg a => a -> GQLError
msg GQLError
text
GQLError -> GQLError -> GQLError
forall a. Semigroup a => a -> a -> a
<> GQLError
", got: "
GQLError -> GQLError -> GQLError
forall a. Semigroup a => a -> a -> a
<> Value s -> GQLError
forall a. Msg a => a -> GQLError
msg Value s
jsType
class EncodeWrapperValue (f :: Type -> Type) where
encodeWrapperValue :: (Monad m) => (a -> m (Value CONST)) -> f a -> m (Value CONST)
instance EncodeWrapperValue Maybe where
encodeWrapperValue :: forall (m :: * -> *) a.
Monad m =>
(a -> m (Value CONST)) -> Maybe a -> m (Value CONST)
encodeWrapperValue = m (Value CONST)
-> (a -> m (Value CONST)) -> Maybe a -> m (Value CONST)
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Value CONST -> m (Value CONST)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value CONST
forall (stage :: Stage). Value stage
Null)
instance EncodeWrapperValue [] where
encodeWrapperValue :: forall (m :: * -> *) a.
Monad m =>
(a -> m (Value CONST)) -> [a] -> m (Value CONST)
encodeWrapperValue a -> m (Value CONST)
f [a]
xs = [Value CONST] -> Value CONST
forall (stage :: Stage). [Value stage] -> Value stage
List ([Value CONST] -> Value CONST)
-> m [Value CONST] -> m (Value CONST)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m (Value CONST)) -> [a] -> m [Value CONST]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse a -> m (Value CONST)
f [a]
xs
instance EncodeWrapperValue Set where
encodeWrapperValue :: forall (m :: * -> *) a.
Monad m =>
(a -> m (Value CONST)) -> Set a -> m (Value CONST)
encodeWrapperValue a -> m (Value CONST)
f = (a -> m (Value CONST)) -> [a] -> m (Value CONST)
forall (f :: * -> *) (m :: * -> *) a.
(EncodeWrapperValue f, Monad m) =>
(a -> m (Value CONST)) -> f a -> m (Value CONST)
forall (m :: * -> *) a.
Monad m =>
(a -> m (Value CONST)) -> [a] -> m (Value CONST)
encodeWrapperValue a -> m (Value CONST)
f ([a] -> m (Value CONST))
-> (Set a -> [a]) -> Set a -> m (Value CONST)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Set a -> [a]
forall a. Set a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList
instance EncodeWrapperValue NonEmpty where
encodeWrapperValue :: forall (m :: * -> *) a.
Monad m =>
(a -> m (Value CONST)) -> NonEmpty a -> m (Value CONST)
encodeWrapperValue a -> m (Value CONST)
f = (a -> m (Value CONST)) -> [a] -> m (Value CONST)
forall (f :: * -> *) (m :: * -> *) a.
(EncodeWrapperValue f, Monad m) =>
(a -> m (Value CONST)) -> f a -> m (Value CONST)
forall (m :: * -> *) a.
Monad m =>
(a -> m (Value CONST)) -> [a] -> m (Value CONST)
encodeWrapperValue a -> m (Value CONST)
f ([a] -> m (Value CONST))
-> (NonEmpty a -> [a]) -> NonEmpty a -> m (Value CONST)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NonEmpty a -> [a]
forall a. NonEmpty a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList
instance EncodeWrapperValue Seq where
encodeWrapperValue :: forall (m :: * -> *) a.
Monad m =>
(a -> m (Value CONST)) -> Seq a -> m (Value CONST)
encodeWrapperValue a -> m (Value CONST)
f = (a -> m (Value CONST)) -> [a] -> m (Value CONST)
forall (f :: * -> *) (m :: * -> *) a.
(EncodeWrapperValue f, Monad m) =>
(a -> m (Value CONST)) -> f a -> m (Value CONST)
forall (m :: * -> *) a.
Monad m =>
(a -> m (Value CONST)) -> [a] -> m (Value CONST)
encodeWrapperValue a -> m (Value CONST)
f ([a] -> m (Value CONST))
-> (Seq a -> [a]) -> Seq a -> m (Value CONST)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Seq a -> [a]
forall a. Seq a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList
instance EncodeWrapperValue Vector where
encodeWrapperValue :: forall (m :: * -> *) a.
Monad m =>
(a -> m (Value CONST)) -> Vector a -> m (Value CONST)
encodeWrapperValue a -> m (Value CONST)
f = (a -> m (Value CONST)) -> [a] -> m (Value CONST)
forall (f :: * -> *) (m :: * -> *) a.
(EncodeWrapperValue f, Monad m) =>
(a -> m (Value CONST)) -> f a -> m (Value CONST)
forall (m :: * -> *) a.
Monad m =>
(a -> m (Value CONST)) -> [a] -> m (Value CONST)
encodeWrapperValue a -> m (Value CONST)
f ([a] -> m (Value CONST))
-> (Vector a -> [a]) -> Vector a -> m (Value CONST)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector a -> [a]
forall a. Vector a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList