module TOML.Lens
( _Table
, _List
, _Double
, _Integer
, _String
, _Bool
, _ZonedTimeV
, _LocalTimeV
, _DayV
, _TimeOfDayV
) where
import Data.Profunctor
import qualified Data.Text as T
import Data.Time
import TOML
prism
:: (Choice p, Applicative f)
=> (b -> t)
-> (s -> Either t a)
-> p a (f b)
-> p s (f t)
prism bt seta = dimap seta (either pure (fmap bt)) . right'
_Table
:: (Choice p, Applicative f)
=> p [(T.Text, Value)] (f [(T.Text, Value)])
-> p Value (f Value)
_Table =
prism Table $ \ n -> case n of
Table v -> pure v
_ -> Left n
_List
:: (Choice p, Applicative f)
=> p [Value] (f [Value])
-> p Value (f Value)
_List =
prism List $ \ n -> case n of
List v -> pure v
_ -> Left n
_Double
:: (Choice p, Applicative f)
=> p Double (f Double)
-> p Value (f Value)
_Double =
prism Double $ \ n -> case n of
Double v -> pure v
_ -> Left n
_Integer
:: (Choice p, Applicative f)
=> p Integer (f Integer)
-> p Value (f Value)
_Integer =
prism Integer $ \ n -> case n of
Integer v -> pure v
_ -> Left n
_String
:: (Choice p, Applicative f)
=> p T.Text (f T.Text)
-> p Value (f Value)
_String =
prism String $ \ n -> case n of
String v -> pure v
_ -> Left n
_Bool
:: (Choice p, Applicative f)
=> p Bool (f Bool)
-> p Value (f Value)
_Bool =
prism Bool $ \ n -> case n of
Bool v -> pure v
_ -> Left n
_ZonedTimeV
:: (Choice p, Applicative f)
=> p ZonedTime (f ZonedTime)
-> p Value (f Value)
_ZonedTimeV =
prism ZonedTimeV $ \ n -> case n of
ZonedTimeV v -> pure v
_ -> Left n
_LocalTimeV
:: (Choice p, Applicative f)
=> p LocalTime (f LocalTime)
-> p Value (f Value)
_LocalTimeV =
prism LocalTimeV $ \ n -> case n of
LocalTimeV v -> pure v
_ -> Left n
_DayV
:: (Choice p, Applicative f)
=> p Day (f Day)
-> p Value (f Value)
_DayV =
prism DayV $ \ n -> case n of
DayV v -> pure v
_ -> Left n
_TimeOfDayV
:: (Choice p, Applicative f)
=> p TimeOfDay (f TimeOfDay)
-> p Value (f Value)
_TimeOfDayV =
prism TimeOfDayV $ \ n -> case n of
TimeOfDayV v -> pure v
_ -> Left n