{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE DeriveTraversable #-}
#if __GLASGOW_HASKELL__ < 800
{-# LANGUAGE ExplicitNamespaces #-}
#endif
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
module Env.Generic
( Record(..)
, Field(..)
#if __GLASGOW_HASKELL__ < 800
, (?)(..)
#else
, type (?)(..)
#endif
, G.Generic
) where
import Control.Applicative (liftA2, (<|>))
import Control.Monad (guard)
import qualified Data.Char as Char
import Data.Int (Int8, Int16, Int32, Int64)
import Data.Word (Word8, Word16, Word32, Word64)
import qualified Data.List as List
import Data.Maybe (fromMaybe)
import Data.Proxy (Proxy(Proxy))
import qualified GHC.Generics as G
import qualified GHC.TypeLits as G
import Numeric.Natural (Natural)
import Prelude hiding (mod)
import qualified Env
class Record e a where
record :: Env.Parser e a
default record :: (r ~ G.Rep a, G.Generic a, GRecord e r) => Env.Parser e a
record =
(r Any -> a) -> Parser e (r Any) -> Parser e a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap r Any -> a
forall a x. Generic a => Rep a x -> a
G.to (State -> Parser e (r Any)
forall k e (f :: k -> *) (a :: k).
GRecord e f =>
State -> Parser e (f a)
gr State :: String -> String -> String -> State
State {statePrefix :: String
statePrefix=String
"", stateCon :: String
stateCon=String
"", stateVar :: String
stateVar=String
""})
data State = State
{ State -> String
statePrefix :: String
, State -> String
stateCon :: String
, State -> String
stateVar :: String
} deriving (Int -> State -> ShowS
[State] -> ShowS
State -> String
(Int -> State -> ShowS)
-> (State -> String) -> ([State] -> ShowS) -> Show State
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [State] -> ShowS
$cshowList :: [State] -> ShowS
show :: State -> String
$cshow :: State -> String
showsPrec :: Int -> State -> ShowS
$cshowsPrec :: Int -> State -> ShowS
Show, State -> State -> Bool
(State -> State -> Bool) -> (State -> State -> Bool) -> Eq State
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: State -> State -> Bool
$c/= :: State -> State -> Bool
== :: State -> State -> Bool
$c== :: State -> State -> Bool
Eq)
class GRecord e f where
gr :: State -> Env.Parser e (f a)
instance GRecord e a => GRecord e (G.D1 c a) where
gr :: State -> Parser e (D1 c a a)
gr =
(a a -> D1 c a a) -> Parser e (a a) -> Parser e (D1 c a a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a a -> D1 c a a
forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
G.M1 (Parser e (a a) -> Parser e (D1 c a a))
-> (State -> Parser e (a a)) -> State -> Parser e (D1 c a a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. State -> Parser e (a a)
forall k e (f :: k -> *) (a :: k).
GRecord e f =>
State -> Parser e (f a)
gr
instance Field e a => GRecord e (G.K1 i a) where
gr :: State -> Parser e (K1 i a a)
gr State {String
stateVar :: String
stateVar :: State -> String
stateVar} =
(a -> K1 i a a) -> Parser e a -> Parser e (K1 i a a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> K1 i a a
forall k i c (p :: k). c -> K1 i c p
G.K1 (String -> Maybe String -> Parser e a
forall e a. Field e a => String -> Maybe String -> Parser e a
field String
stateVar Maybe String
forall a. Maybe a
Nothing)
instance (G.Constructor c, GRecord e a) => GRecord e (G.C1 c a) where
gr :: State -> Parser e (C1 c a a)
gr State
state =
(a a -> C1 c a a) -> Parser e (a a) -> Parser e (C1 c a a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a a -> C1 c a a
forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
G.M1 (State -> Parser e (a a)
forall k e (f :: k -> *) (a :: k).
GRecord e f =>
State -> Parser e (f a)
gr State
state {stateCon :: String
stateCon=String
con})
where
con :: String
con = M1 Any c Proxy Any -> String
forall k (c :: k) k1 (t :: k -> (k1 -> *) -> k1 -> *)
(f :: k1 -> *) (a :: k1).
Constructor c =>
t c f a -> String
G.conName (Proxy b -> M1 t c Proxy b
forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
G.M1 Proxy b
forall k (t :: k). Proxy t
Proxy :: G.M1 t c Proxy b)
instance (GRecord e f, GRecord e g) => GRecord e (f G.:*: g) where
gr :: State -> Parser e ((:*:) f g a)
gr State
x =
(f a -> g a -> (:*:) f g a)
-> Parser e (f a) -> Parser e (g a) -> Parser e ((:*:) f g a)
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 f a -> g a -> (:*:) f g a
forall k (f :: k -> *) (g :: k -> *) (p :: k).
f p -> g p -> (:*:) f g p
(G.:*:) (State -> Parser e (f a)
forall k e (f :: k -> *) (a :: k).
GRecord e f =>
State -> Parser e (f a)
gr State
x) (State -> Parser e (g a)
forall k e (f :: k -> *) (a :: k).
GRecord e f =>
State -> Parser e (f a)
gr State
x)
instance (GRecord e f, GRecord e g) => GRecord e (f G.:+: g) where
gr :: State -> Parser e ((:+:) f g a)
gr State
x =
(f a -> (:+:) f g a) -> Parser e (f a) -> Parser e ((:+:) f g a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap f a -> (:+:) f g a
forall k (f :: k -> *) (g :: k -> *) (p :: k). f p -> (:+:) f g p
G.L1 (State -> Parser e (f a)
forall k e (f :: k -> *) (a :: k).
GRecord e f =>
State -> Parser e (f a)
gr State
x) Parser e ((:+:) f g a)
-> Parser e ((:+:) f g a) -> Parser e ((:+:) f g a)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (g a -> (:+:) f g a) -> Parser e (g a) -> Parser e ((:+:) f g a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap g a -> (:+:) f g a
forall k (f :: k -> *) (g :: k -> *) (p :: k). g p -> (:+:) f g p
G.R1 (State -> Parser e (g a)
forall k e (f :: k -> *) (a :: k).
GRecord e f =>
State -> Parser e (f a)
gr State
x)
#if __GLASGOW_HASKELL__ < 800
type family Type x :: ConType where
Type G.NoSelector = 'Plain
Type x = 'Record
data ConType = Plain | Record
instance (G.Selector c, Type c ~ 'Record, GRecord e a) => GRecord e (G.S1 c a) where
#else
instance (G.Selector c, c ~ 'G.MetaSel ('Just x1) x2 x3 x4, GRecord e a) => GRecord e (G.S1 c a) where
#endif
gr :: State -> Parser e (S1 c a a)
gr state :: State
state@State {String
statePrefix :: String
statePrefix :: State -> String
statePrefix, String
stateCon :: String
stateCon :: State -> String
stateCon} =
(a a -> S1 c a a) -> Parser e (a a) -> Parser e (S1 c a a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a a -> S1 c a a
forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
G.M1 (State -> Parser e (a a)
forall k e (f :: k -> *) (a :: k).
GRecord e f =>
State -> Parser e (f a)
gr State
state {stateVar :: String
stateVar=String
statePrefix String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
suffix})
where
sel :: String
sel = M1 Any c Proxy Any -> String
forall k (s :: k) k1 (t :: k -> (k1 -> *) -> k1 -> *)
(f :: k1 -> *) (a :: k1).
Selector s =>
t s f a -> String
G.selName (Proxy b -> M1 t c Proxy b
forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
G.M1 Proxy b
forall k (t :: k). Proxy t
Proxy :: G.M1 t c Proxy b)
suffix :: String
suffix = let
x :: String
x = ShowS
camelTo2 String
sel
in String -> Maybe String -> String
forall a. a -> Maybe a -> a
fromMaybe String
x (Maybe String -> String) -> Maybe String -> String
forall a b. (a -> b) -> a -> b
$ do
String
y <- String -> String -> Maybe String
forall a. Eq a => [a] -> [a] -> Maybe [a]
List.stripPrefix ((Char -> Char) -> ShowS
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
Char.toLower String
stateCon) String
sel
ShowS
camelTo2 String
y String -> Maybe () -> Maybe String
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Bool -> Maybe ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> Bool
not (String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
List.null String
y))
camelTo2 :: String -> String
camelTo2 :: ShowS
camelTo2 = (Char -> Char) -> ShowS
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
Char.toUpper ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
go2 ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
go1
where
go1 :: ShowS
go1 String
"" = String
""
go1 (Char
x:Char
u:Char
l:String
xs) | Char -> Bool
Char.isUpper Char
u Bool -> Bool -> Bool
&& Char -> Bool
Char.isLower Char
l = Char
x Char -> ShowS
forall a. a -> [a] -> [a]
: Char
'_' Char -> ShowS
forall a. a -> [a] -> [a]
: Char
u Char -> ShowS
forall a. a -> [a] -> [a]
: Char
l Char -> ShowS
forall a. a -> [a] -> [a]
: ShowS
go1 String
xs
go1 (Char
x:String
xs) = Char
x Char -> ShowS
forall a. a -> [a] -> [a]
: ShowS
go1 String
xs
go2 :: ShowS
go2 String
"" = String
""
go2 (Char
l:Char
u:String
xs) | Char -> Bool
Char.isLower Char
l Bool -> Bool -> Bool
&& Char -> Bool
Char.isUpper Char
u = Char
l Char -> ShowS
forall a. a -> [a] -> [a]
: Char
'_' Char -> ShowS
forall a. a -> [a] -> [a]
: Char
u Char -> ShowS
forall a. a -> [a] -> [a]
: ShowS
go2 String
xs
go2 (Char
x:String
xs) = Char
x Char -> ShowS
forall a. a -> [a] -> [a]
: ShowS
go2 String
xs
class Field e a where
field :: String -> Maybe String -> Env.Parser e a
default field :: (Env.AsUnset e, Env.AsUnread e, Read a) => String -> Maybe String -> Env.Parser e a
field String
name Maybe String
help =
Reader e a -> String -> Mod Var a -> Parser e a
forall e a.
AsUnset e =>
Reader e a -> String -> Mod Var a -> Parser e a
Env.var Reader e a
forall e a. (AsUnread e, Read a) => Reader e a
Env.auto String
name ((String -> Mod Var a) -> Maybe String -> Mod Var a
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap String -> Mod Var a
forall (t :: * -> *) a. HasHelp t => String -> Mod t a
Env.help Maybe String
help)
instance (Env.AsUnset e, Env.AsUnread e) => Field e Int
instance (Env.AsUnset e, Env.AsUnread e) => Field e Int8
instance (Env.AsUnset e, Env.AsUnread e) => Field e Int16
instance (Env.AsUnset e, Env.AsUnread e) => Field e Int32
instance (Env.AsUnset e, Env.AsUnread e) => Field e Int64
instance (Env.AsUnset e, Env.AsUnread e) => Field e Integer
instance (Env.AsUnset e, Env.AsUnread e) => Field e Word
instance (Env.AsUnset e, Env.AsUnread e) => Field e Word8
instance (Env.AsUnset e, Env.AsUnread e) => Field e Word16
instance (Env.AsUnset e, Env.AsUnread e) => Field e Word32
instance (Env.AsUnset e, Env.AsUnread e) => Field e Word64
instance (Env.AsUnset e, Env.AsUnread e) => Field e Natural
instance (Env.AsUnset e, Env.AsUnread e) => Field e Float
instance (Env.AsUnset e, Env.AsUnread e) => Field e Double
instance Env.AsUnset e => Field e String where
field :: String -> Maybe String -> Parser e String
field String
name Maybe String
help =
Reader e String -> String -> Mod Var String -> Parser e String
forall e a.
AsUnset e =>
Reader e a -> String -> Mod Var a -> Parser e a
Env.var Reader e String
forall s e. IsString s => Reader e s
Env.str String
name ((String -> Mod Var String) -> Maybe String -> Mod Var String
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap String -> Mod Var String
forall (t :: * -> *) a. HasHelp t => String -> Mod t a
Env.help Maybe String
help)
instance (Env.AsUnset e, Env.AsUnread e) => Field e Char where
field :: String -> Maybe String -> Parser e Char
field String
name Maybe String
help =
Reader e Char -> String -> Mod Var Char -> Parser e Char
forall e a.
AsUnset e =>
Reader e a -> String -> Mod Var a -> Parser e a
Env.var Reader e Char
reader String
name ((String -> Mod Var Char) -> Maybe String -> Mod Var Char
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap String -> Mod Var Char
forall (t :: * -> *) a. HasHelp t => String -> Mod t a
Env.help Maybe String
help)
where
reader :: Reader e Char
reader = \case
[Char
c] -> Char -> Either e Char
forall (f :: * -> *) a. Applicative f => a -> f a
pure Char
c
String
str -> e -> Either e Char
forall a b. a -> Either a b
Left (String -> e
forall e. AsUnread e => String -> e
Env.unread String
str)
instance Field e Bool where
field :: String -> Maybe String -> Parser e Bool
field String
name Maybe String
help =
String -> Mod Flag Bool -> Parser e Bool
forall e. String -> Mod Flag Bool -> Parser e Bool
Env.switch String
name ((String -> Mod Flag Bool) -> Maybe String -> Mod Flag Bool
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap String -> Mod Flag Bool
forall (t :: * -> *) a. HasHelp t => String -> Mod t a
Env.help Maybe String
help)
newtype a ? tag = Help { (a ? tag) -> a
unHelp :: a }
deriving (Int -> (a ? tag) -> ShowS
[a ? tag] -> ShowS
(a ? tag) -> String
(Int -> (a ? tag) -> ShowS)
-> ((a ? tag) -> String) -> ([a ? tag] -> ShowS) -> Show (a ? tag)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall a k (tag :: k). Show a => Int -> (a ? tag) -> ShowS
forall a k (tag :: k). Show a => [a ? tag] -> ShowS
forall a k (tag :: k). Show a => (a ? tag) -> String
showList :: [a ? tag] -> ShowS
$cshowList :: forall a k (tag :: k). Show a => [a ? tag] -> ShowS
show :: (a ? tag) -> String
$cshow :: forall a k (tag :: k). Show a => (a ? tag) -> String
showsPrec :: Int -> (a ? tag) -> ShowS
$cshowsPrec :: forall a k (tag :: k). Show a => Int -> (a ? tag) -> ShowS
Show, (a ? tag) -> (a ? tag) -> Bool
((a ? tag) -> (a ? tag) -> Bool)
-> ((a ? tag) -> (a ? tag) -> Bool) -> Eq (a ? tag)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall a k (tag :: k). Eq a => (a ? tag) -> (a ? tag) -> Bool
/= :: (a ? tag) -> (a ? tag) -> Bool
$c/= :: forall a k (tag :: k). Eq a => (a ? tag) -> (a ? tag) -> Bool
== :: (a ? tag) -> (a ? tag) -> Bool
$c== :: forall a k (tag :: k). Eq a => (a ? tag) -> (a ? tag) -> Bool
Eq, (a -> b) -> (a ? a) -> a ? b
(forall a b. (a -> b) -> (a ? a) -> a ? b)
-> (forall a b. a -> (a ? b) -> a ? a) -> Functor ((?) a)
forall a b. a -> (a ? b) -> a ? a
forall a b. (a -> b) -> (a ? a) -> a ? b
forall a a b. a -> (a ? b) -> a ? a
forall a a b. (a -> b) -> (a ? a) -> a ? b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> (a ? b) -> a ? a
$c<$ :: forall a a b. a -> (a ? b) -> a ? a
fmap :: (a -> b) -> (a ? a) -> a ? b
$cfmap :: forall a a b. (a -> b) -> (a ? a) -> a ? b
Functor, (a -> m) -> (a ? a) -> m
(forall m. Monoid m => (a ? m) -> m)
-> (forall m a. Monoid m => (a -> m) -> (a ? a) -> m)
-> (forall m a. Monoid m => (a -> m) -> (a ? a) -> m)
-> (forall a b. (a -> b -> b) -> b -> (a ? a) -> b)
-> (forall a b. (a -> b -> b) -> b -> (a ? a) -> b)
-> (forall b a. (b -> a -> b) -> b -> (a ? a) -> b)
-> (forall b a. (b -> a -> b) -> b -> (a ? a) -> b)
-> (forall a. (a -> a -> a) -> (a ? a) -> a)
-> (forall a. (a -> a -> a) -> (a ? a) -> a)
-> (forall a. (a ? a) -> [a])
-> (forall a. (a ? a) -> Bool)
-> (forall a. (a ? a) -> Int)
-> (forall a. Eq a => a -> (a ? a) -> Bool)
-> (forall a. Ord a => (a ? a) -> a)
-> (forall a. Ord a => (a ? a) -> a)
-> (forall a. Num a => (a ? a) -> a)
-> (forall a. Num a => (a ? a) -> a)
-> Foldable ((?) a)
forall a. Eq a => a -> (a ? a) -> Bool
forall a. Num a => (a ? a) -> a
forall a. Ord a => (a ? a) -> a
forall m. Monoid m => (a ? m) -> m
forall a. (a ? a) -> Bool
forall a. (a ? a) -> Int
forall a. (a ? a) -> [a]
forall a. (a -> a -> a) -> (a ? a) -> a
forall a a. Eq a => a -> (a ? a) -> Bool
forall a a. Num a => (a ? a) -> a
forall a a. Ord a => (a ? a) -> a
forall m a. Monoid m => (a -> m) -> (a ? a) -> m
forall a m. Monoid m => (a ? m) -> m
forall a a. (a ? a) -> Bool
forall a a. (a ? a) -> Int
forall a a. (a ? a) -> [a]
forall b a. (b -> a -> b) -> b -> (a ? a) -> b
forall a b. (a -> b -> b) -> b -> (a ? a) -> b
forall a a. (a -> a -> a) -> (a ? a) -> a
forall a m a. Monoid m => (a -> m) -> (a ? a) -> m
forall a b a. (b -> a -> b) -> b -> (a ? a) -> b
forall a a b. (a -> b -> b) -> b -> (a ? 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 :: (a ? a) -> a
$cproduct :: forall a a. Num a => (a ? a) -> a
sum :: (a ? a) -> a
$csum :: forall a a. Num a => (a ? a) -> a
minimum :: (a ? a) -> a
$cminimum :: forall a a. Ord a => (a ? a) -> a
maximum :: (a ? a) -> a
$cmaximum :: forall a a. Ord a => (a ? a) -> a
elem :: a -> (a ? a) -> Bool
$celem :: forall a a. Eq a => a -> (a ? a) -> Bool
length :: (a ? a) -> Int
$clength :: forall a a. (a ? a) -> Int
null :: (a ? a) -> Bool
$cnull :: forall a a. (a ? a) -> Bool
toList :: (a ? a) -> [a]
$ctoList :: forall a a. (a ? a) -> [a]
foldl1 :: (a -> a -> a) -> (a ? a) -> a
$cfoldl1 :: forall a a. (a -> a -> a) -> (a ? a) -> a
foldr1 :: (a -> a -> a) -> (a ? a) -> a
$cfoldr1 :: forall a a. (a -> a -> a) -> (a ? a) -> a
foldl' :: (b -> a -> b) -> b -> (a ? a) -> b
$cfoldl' :: forall a b a. (b -> a -> b) -> b -> (a ? a) -> b
foldl :: (b -> a -> b) -> b -> (a ? a) -> b
$cfoldl :: forall a b a. (b -> a -> b) -> b -> (a ? a) -> b
foldr' :: (a -> b -> b) -> b -> (a ? a) -> b
$cfoldr' :: forall a a b. (a -> b -> b) -> b -> (a ? a) -> b
foldr :: (a -> b -> b) -> b -> (a ? a) -> b
$cfoldr :: forall a a b. (a -> b -> b) -> b -> (a ? a) -> b
foldMap' :: (a -> m) -> (a ? a) -> m
$cfoldMap' :: forall a m a. Monoid m => (a -> m) -> (a ? a) -> m
foldMap :: (a -> m) -> (a ? a) -> m
$cfoldMap :: forall a m a. Monoid m => (a -> m) -> (a ? a) -> m
fold :: (a ? m) -> m
$cfold :: forall a m. Monoid m => (a ? m) -> m
Foldable, Functor ((?) a)
Foldable ((?) a)
Functor ((?) a)
-> Foldable ((?) a)
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> (a ? a) -> f (a ? b))
-> (forall (f :: * -> *) a.
Applicative f =>
(a ? f a) -> f (a ? a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> (a ? a) -> m (a ? b))
-> (forall (m :: * -> *) a. Monad m => (a ? m a) -> m (a ? a))
-> Traversable ((?) a)
(a -> f b) -> (a ? a) -> f (a ? b)
forall a. Functor ((?) a)
forall a. Foldable ((?) a)
forall a (m :: * -> *) a. Monad m => (a ? m a) -> m (a ? a)
forall a (f :: * -> *) a. Applicative f => (a ? f a) -> f (a ? a)
forall a (m :: * -> *) a b.
Monad m =>
(a -> m b) -> (a ? a) -> m (a ? b)
forall a (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> (a ? a) -> f (a ? b)
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 => (a ? m a) -> m (a ? a)
forall (f :: * -> *) a. Applicative f => (a ? f a) -> f (a ? a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> (a ? a) -> m (a ? b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> (a ? a) -> f (a ? b)
sequence :: (a ? m a) -> m (a ? a)
$csequence :: forall a (m :: * -> *) a. Monad m => (a ? m a) -> m (a ? a)
mapM :: (a -> m b) -> (a ? a) -> m (a ? b)
$cmapM :: forall a (m :: * -> *) a b.
Monad m =>
(a -> m b) -> (a ? a) -> m (a ? b)
sequenceA :: (a ? f a) -> f (a ? a)
$csequenceA :: forall a (f :: * -> *) a. Applicative f => (a ? f a) -> f (a ? a)
traverse :: (a -> f b) -> (a ? a) -> f (a ? b)
$ctraverse :: forall a (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> (a ? a) -> f (a ? b)
$cp2Traversable :: forall a. Foldable ((?) a)
$cp1Traversable :: forall a. Functor ((?) a)
Traversable)
instance (G.KnownSymbol tag, Field e a) => Field e (a ? tag) where
field :: String -> Maybe String -> Parser e (a ? tag)
field String
name Maybe String
_ =
(a -> a ? tag) -> Parser e a -> Parser e (a ? tag)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a ? tag
forall k a (tag :: k). a -> a ? tag
Help (String -> Maybe String -> Parser e a
forall e a. Field e a => String -> Maybe String -> Parser e a
field String
name (String -> Maybe String
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Proxy tag -> String
forall (n :: Symbol) (proxy :: Symbol -> *).
KnownSymbol n =>
proxy n -> String
G.symbolVal (Proxy tag
forall k (t :: k). Proxy t
Proxy :: Proxy tag))))