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'
{-# INLINE prism #-}
_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 -> Right v
_ -> Left n
{-# INLINE _Table #-}
_List
:: (Choice p, Applicative f)
=> p [Value] (f [Value])
-> p Value (f Value)
_List =
prism List $ \ n -> case n of
List v -> Right v
_ -> Left n
{-# INLINE _List #-}
_Double
:: (Choice p, Applicative f)
=> p Double (f Double)
-> p Value (f Value)
_Double =
prism Double $ \ n -> case n of
Double v -> Right v
_ -> Left n
{-# INLINE _Double #-}
_Integer
:: (Choice p, Applicative f)
=> p Integer (f Integer)
-> p Value (f Value)
_Integer =
prism Integer $ \ n -> case n of
Integer v -> Right v
_ -> Left n
{-# INLINE _Integer #-}
_String
:: (Choice p, Applicative f)
=> p T.Text (f T.Text)
-> p Value (f Value)
_String =
prism String $ \ n -> case n of
String v -> Right v
_ -> Left n
{-# INLINE _String #-}
_Bool
:: (Choice p, Applicative f)
=> p Bool (f Bool)
-> p Value (f Value)
_Bool =
prism Bool $ \ n -> case n of
Bool v -> Right v
_ -> Left n
{-# INLINE _Bool #-}
_ZonedTimeV
:: (Choice p, Applicative f)
=> p ZonedTime (f ZonedTime)
-> p Value (f Value)
_ZonedTimeV =
prism ZonedTimeV $ \ n -> case n of
ZonedTimeV v -> Right v
_ -> Left n
{-# INLINE _ZonedTimeV #-}
_LocalTimeV
:: (Choice p, Applicative f)
=> p LocalTime (f LocalTime)
-> p Value (f Value)
_LocalTimeV =
prism LocalTimeV $ \ n -> case n of
LocalTimeV v -> Right v
_ -> Left n
{-# INLINE _LocalTimeV #-}
_DayV
:: (Choice p, Applicative f)
=> p Day (f Day)
-> p Value (f Value)
_DayV =
prism DayV $ \ n -> case n of
DayV v -> Right v
_ -> Left n
{-# INLINE _DayV #-}
_TimeOfDayV
:: (Choice p, Applicative f)
=> p TimeOfDay (f TimeOfDay)
-> p Value (f Value)
_TimeOfDayV =
prism TimeOfDayV $ \ n -> case n of
TimeOfDayV v -> Right v
_ -> Left n
{-# INLINE _TimeOfDayV #-}