{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# OPTIONS_GHC -Wno-unused-imports #-}
module Df1.Types
( Log (Log, log_time, log_level, log_path, log_message)
, Level (Debug, Info, Notice, Warning, Error, Critical, Alert, Emergency)
, Path (Attr, Push)
, ToPath (path)
, Segment
, unSegment
, ToSegment (segment)
, Key
, unKey
, ToKey (key)
, Value
, unValue
, ToValue (value)
, Message
, unMessage
, ToMessage (message)
) where
import Control.Exception (SomeException)
import Data.Coerce (coerce)
import qualified Data.Fixed as Fixed
import Data.Foldable (toList)
import Data.Int (Int16, Int32, Int64, Int8)
import Data.Semigroup (Semigroup ((<>)))
import Data.Sequence as Seq
import Data.String (IsString (fromString))
import qualified Data.Text as T
import qualified Data.Text.Lazy as TL
import qualified Data.Text.Lazy.Builder as TB
import qualified Data.Time as Time
import qualified Data.Time.Clock.System as Time
import qualified Data.Time.Format.ISO8601 as Time
import Data.Word (Word16, Word32, Word64, Word8)
import Numeric.Natural (Natural)
data Log = Log
{ Log -> SystemTime
log_time :: !Time.SystemTime
, Log -> Level
log_level :: !Level
, Log -> Seq Path
log_path :: !(Seq.Seq Path)
, Log -> Message
log_message :: !Message
}
deriving (Log -> Log -> Bool
(Log -> Log -> Bool) -> (Log -> Log -> Bool) -> Eq Log
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Log -> Log -> Bool
== :: Log -> Log -> Bool
$c/= :: Log -> Log -> Bool
/= :: Log -> Log -> Bool
Eq, Int -> Log -> ShowS
[Log] -> ShowS
Log -> String
(Int -> Log -> ShowS)
-> (Log -> String) -> ([Log] -> ShowS) -> Show Log
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Log -> ShowS
showsPrec :: Int -> Log -> ShowS
$cshow :: Log -> String
show :: Log -> String
$cshowList :: [Log] -> ShowS
showList :: [Log] -> ShowS
Show)
newtype Message = Message TL.Text
deriving (Message -> Message -> Bool
(Message -> Message -> Bool)
-> (Message -> Message -> Bool) -> Eq Message
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Message -> Message -> Bool
== :: Message -> Message -> Bool
$c/= :: Message -> Message -> Bool
/= :: Message -> Message -> Bool
Eq, Int -> Message -> ShowS
[Message] -> ShowS
Message -> String
(Int -> Message -> ShowS)
-> (Message -> String) -> ([Message] -> ShowS) -> Show Message
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Message -> ShowS
showsPrec :: Int -> Message -> ShowS
$cshow :: Message -> String
show :: Message -> String
$cshowList :: [Message] -> ShowS
showList :: [Message] -> ShowS
Show)
unMessage :: Message -> TL.Text
unMessage :: Message -> Text
unMessage = Message -> Text
forall a b. Coercible a b => a -> b
coerce
{-# INLINE unMessage #-}
instance IsString Message where
fromString :: String -> Message
fromString = String -> Message
forall a. ToMessage a => a -> Message
message
{-# INLINE fromString #-}
instance Semigroup Message where
<> :: Message -> Message -> Message
(<>) = (Text -> Text -> Text) -> Message -> Message -> Message
forall a b. Coercible a b => a -> b
coerce (Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
(<>) :: TL.Text -> TL.Text -> TL.Text)
{-# INLINE (<>) #-}
instance Monoid Message where
mempty :: Message
mempty = Text -> Message
Message Text
forall a. Monoid a => a
mempty
{-# INLINE mempty #-}
class ToMessage a where
message :: a -> Message
instance ToMessage Message where
message :: Message -> Message
message = Message -> Message
forall a. a -> a
id
{-# INLINE message #-}
instance ToMessage TL.Text where
message :: Text -> Message
message = Text -> Message
Message
{-# INLINE message #-}
instance ToMessage TB.Builder where
message :: Builder -> Message
message = Text -> Message
Message (Text -> Message) -> (Builder -> Text) -> Builder -> Message
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Builder -> Text
TB.toLazyText
{-# INLINE message #-}
instance ToMessage T.Text where
message :: Text -> Message
message = Text -> Message
Message (Text -> Message) -> (Text -> Text) -> Text -> Message
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
TL.fromStrict
{-# INLINE message #-}
instance ToMessage String where
message :: String -> Message
message = Text -> Message
Message (Text -> Message) -> (String -> Text) -> String -> Message
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
TL.pack
{-# INLINE message #-}
instance ToMessage SomeException where
message :: SomeException -> Message
message = String -> Message
forall a. ToMessage a => a -> Message
message (String -> Message)
-> (SomeException -> String) -> SomeException -> Message
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SomeException -> String
forall a. Show a => a -> String
show
{-# INLINE message #-}
data Level
=
Debug
|
Info
|
Notice
|
Warning
|
Error
|
Critical
|
Alert
|
Emergency
deriving (Level -> Level -> Bool
(Level -> Level -> Bool) -> (Level -> Level -> Bool) -> Eq Level
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Level -> Level -> Bool
== :: Level -> Level -> Bool
$c/= :: Level -> Level -> Bool
/= :: Level -> Level -> Bool
Eq, Int -> Level -> ShowS
[Level] -> ShowS
Level -> String
(Int -> Level -> ShowS)
-> (Level -> String) -> ([Level] -> ShowS) -> Show Level
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Level -> ShowS
showsPrec :: Int -> Level -> ShowS
$cshow :: Level -> String
show :: Level -> String
$cshowList :: [Level] -> ShowS
showList :: [Level] -> ShowS
Show, ReadPrec [Level]
ReadPrec Level
Int -> ReadS Level
ReadS [Level]
(Int -> ReadS Level)
-> ReadS [Level]
-> ReadPrec Level
-> ReadPrec [Level]
-> Read Level
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Level
readsPrec :: Int -> ReadS Level
$creadList :: ReadS [Level]
readList :: ReadS [Level]
$creadPrec :: ReadPrec Level
readPrec :: ReadPrec Level
$creadListPrec :: ReadPrec [Level]
readListPrec :: ReadPrec [Level]
Read, Level
Level -> Level -> Bounded Level
forall a. a -> a -> Bounded a
$cminBound :: Level
minBound :: Level
$cmaxBound :: Level
maxBound :: Level
Bounded, Int -> Level
Level -> Int
Level -> [Level]
Level -> Level
Level -> Level -> [Level]
Level -> Level -> Level -> [Level]
(Level -> Level)
-> (Level -> Level)
-> (Int -> Level)
-> (Level -> Int)
-> (Level -> [Level])
-> (Level -> Level -> [Level])
-> (Level -> Level -> [Level])
-> (Level -> Level -> Level -> [Level])
-> Enum Level
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: Level -> Level
succ :: Level -> Level
$cpred :: Level -> Level
pred :: Level -> Level
$ctoEnum :: Int -> Level
toEnum :: Int -> Level
$cfromEnum :: Level -> Int
fromEnum :: Level -> Int
$cenumFrom :: Level -> [Level]
enumFrom :: Level -> [Level]
$cenumFromThen :: Level -> Level -> [Level]
enumFromThen :: Level -> Level -> [Level]
$cenumFromTo :: Level -> Level -> [Level]
enumFromTo :: Level -> Level -> [Level]
$cenumFromThenTo :: Level -> Level -> Level -> [Level]
enumFromThenTo :: Level -> Level -> Level -> [Level]
Enum)
deriving instance Ord Level
newtype Segment = Segment TL.Text
deriving (Segment -> Segment -> Bool
(Segment -> Segment -> Bool)
-> (Segment -> Segment -> Bool) -> Eq Segment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Segment -> Segment -> Bool
== :: Segment -> Segment -> Bool
$c/= :: Segment -> Segment -> Bool
/= :: Segment -> Segment -> Bool
Eq, Int -> Segment -> ShowS
[Segment] -> ShowS
Segment -> String
(Int -> Segment -> ShowS)
-> (Segment -> String) -> ([Segment] -> ShowS) -> Show Segment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Segment -> ShowS
showsPrec :: Int -> Segment -> ShowS
$cshow :: Segment -> String
show :: Segment -> String
$cshowList :: [Segment] -> ShowS
showList :: [Segment] -> ShowS
Show)
unSegment :: Segment -> TL.Text
unSegment :: Segment -> Text
unSegment = Segment -> Text
forall a b. Coercible a b => a -> b
coerce
{-# INLINE unSegment #-}
instance IsString Segment where
fromString :: String -> Segment
fromString = String -> Segment
forall a. ToSegment a => a -> Segment
segment
{-# INLINE fromString #-}
instance Semigroup Segment where
<> :: Segment -> Segment -> Segment
(<>) = (Text -> Text -> Text) -> Segment -> Segment -> Segment
forall a b. Coercible a b => a -> b
coerce (Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
(<>) :: TL.Text -> TL.Text -> TL.Text)
{-# INLINE (<>) #-}
instance Monoid Segment where
mempty :: Segment
mempty = Text -> Segment
Segment Text
forall a. Monoid a => a
mempty
{-# INLINE mempty #-}
class ToSegment a where
segment :: a -> Segment
instance ToSegment Segment where
segment :: Segment -> Segment
segment = Segment -> Segment
forall a. a -> a
id
{-# INLINE segment #-}
instance ToSegment TL.Text where
segment :: Text -> Segment
segment = Text -> Segment
Segment
{-# INLINE segment #-}
instance ToSegment TB.Builder where
segment :: Builder -> Segment
segment = Text -> Segment
Segment (Text -> Segment) -> (Builder -> Text) -> Builder -> Segment
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Builder -> Text
TB.toLazyText
{-# INLINE segment #-}
instance ToSegment T.Text where
segment :: Text -> Segment
segment = Text -> Segment
Segment (Text -> Segment) -> (Text -> Text) -> Text -> Segment
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
TL.fromStrict
{-# INLINE segment #-}
instance ToSegment String where
segment :: String -> Segment
segment = Text -> Segment
Segment (Text -> Segment) -> (String -> Text) -> String -> Segment
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
TL.pack
{-# INLINE segment #-}
instance ToSegment Char where
segment :: Char -> Segment
segment = Text -> Segment
Segment (Text -> Segment) -> (Char -> Text) -> Char -> Segment
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Text
TL.singleton
{-# INLINE segment #-}
newtype Key = Key TL.Text
deriving (Key -> Key -> Bool
(Key -> Key -> Bool) -> (Key -> Key -> Bool) -> Eq Key
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Key -> Key -> Bool
== :: Key -> Key -> Bool
$c/= :: Key -> Key -> Bool
/= :: Key -> Key -> Bool
Eq, Int -> Key -> ShowS
[Key] -> ShowS
Key -> String
(Int -> Key -> ShowS)
-> (Key -> String) -> ([Key] -> ShowS) -> Show Key
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Key -> ShowS
showsPrec :: Int -> Key -> ShowS
$cshow :: Key -> String
show :: Key -> String
$cshowList :: [Key] -> ShowS
showList :: [Key] -> ShowS
Show)
unKey :: Key -> TL.Text
unKey :: Key -> Text
unKey = Key -> Text
forall a b. Coercible a b => a -> b
coerce
{-# INLINE unKey #-}
instance IsString Key where
fromString :: String -> Key
fromString = String -> Key
forall a. ToKey a => a -> Key
key
{-# INLINE fromString #-}
instance Semigroup Key where
<> :: Key -> Key -> Key
(<>) = (Text -> Text -> Text) -> Key -> Key -> Key
forall a b. Coercible a b => a -> b
coerce (Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
(<>) :: TL.Text -> TL.Text -> TL.Text)
{-# INLINE (<>) #-}
instance Monoid Key where
mempty :: Key
mempty = Text -> Key
Key Text
forall a. Monoid a => a
mempty
{-# INLINE mempty #-}
class ToKey a where
key :: a -> Key
instance ToKey Key where
key :: Key -> Key
key = Key -> Key
forall a. a -> a
id
{-# INLINE key #-}
instance ToKey TL.Text where
key :: Text -> Key
key = Text -> Key
Key
{-# INLINE key #-}
instance ToKey TB.Builder where
key :: Builder -> Key
key = Text -> Key
Key (Text -> Key) -> (Builder -> Text) -> Builder -> Key
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Builder -> Text
TB.toLazyText
{-# INLINE key #-}
instance ToKey T.Text where
key :: Text -> Key
key = Text -> Key
Key (Text -> Key) -> (Text -> Text) -> Text -> Key
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
TL.fromStrict
{-# INLINE key #-}
instance ToKey String where
key :: String -> Key
key = Text -> Key
Key (Text -> Key) -> (String -> Text) -> String -> Key
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
TL.pack
{-# INLINE key #-}
instance ToKey Char where
key :: Char -> Key
key = Text -> Key
Key (Text -> Key) -> (Char -> Text) -> Char -> Key
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Text
TL.singleton
{-# INLINE key #-}
newtype Value = Value TL.Text
deriving (Value -> Value -> Bool
(Value -> Value -> Bool) -> (Value -> Value -> Bool) -> Eq Value
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Value -> Value -> Bool
== :: Value -> Value -> Bool
$c/= :: Value -> Value -> Bool
/= :: Value -> Value -> Bool
Eq, Int -> Value -> ShowS
[Value] -> ShowS
Value -> String
(Int -> Value -> ShowS)
-> (Value -> String) -> ([Value] -> ShowS) -> Show Value
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Value -> ShowS
showsPrec :: Int -> Value -> ShowS
$cshow :: Value -> String
show :: Value -> String
$cshowList :: [Value] -> ShowS
showList :: [Value] -> ShowS
Show)
unValue :: Value -> TL.Text
unValue :: Value -> Text
unValue = Value -> Text
forall a b. Coercible a b => a -> b
coerce
{-# INLINE unValue #-}
instance IsString Value where
fromString :: String -> Value
fromString = String -> Value
forall a. ToValue a => a -> Value
value
{-# INLINE fromString #-}
instance Semigroup Value where
<> :: Value -> Value -> Value
(<>) = (Text -> Text -> Text) -> Value -> Value -> Value
forall a b. Coercible a b => a -> b
coerce (Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
(<>) :: TL.Text -> TL.Text -> TL.Text)
{-# INLINE (<>) #-}
instance Monoid Value where
mempty :: Value
mempty = Text -> Value
Value Text
forall a. Monoid a => a
mempty
{-# INLINE mempty #-}
class ToValue a where
value :: a -> Value
instance ToValue Value where
value :: Value -> Value
value = Value -> Value
forall a. a -> a
id
{-# INLINE value #-}
instance ToValue TL.Text where
value :: Text -> Value
value = Text -> Value
Value
{-# INLINE value #-}
instance ToValue TB.Builder where
value :: Builder -> Value
value = Text -> Value
Value (Text -> Value) -> (Builder -> Text) -> Builder -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Builder -> Text
TB.toLazyText
{-# INLINE value #-}
instance ToValue T.Text where
value :: Text -> Value
value = Text -> Value
Value (Text -> Value) -> (Text -> Text) -> Text -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
TL.fromStrict
{-# INLINE value #-}
instance ToValue String where
value :: String -> Value
value = Text -> Value
Value (Text -> Value) -> (String -> Text) -> String -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
TL.pack
{-# INLINE value #-}
instance ToValue SomeException where
value :: SomeException -> Value
value = String -> Value
forall a. ToValue a => a -> Value
value (String -> Value)
-> (SomeException -> String) -> SomeException -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SomeException -> String
forall a. Show a => a -> String
show
{-# INLINE value #-}
instance ToValue Bool where
value :: Bool -> Value
value = \Bool
b -> if Bool
b then Value
"true" else Value
"false"
{-# INLINE value #-}
instance ToValue Char where
value :: Char -> Value
value = Text -> Value
Value (Text -> Value) -> (Char -> Text) -> Char -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Text
TL.singleton
{-# INLINE value #-}
instance ToValue Int where
value :: Int -> Value
value = String -> Value
forall a. ToValue a => a -> Value
value (String -> Value) -> (Int -> String) -> Int -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> String
forall a. Show a => a -> String
show
{-# INLINE value #-}
instance ToValue Int8 where
value :: Int8 -> Value
value = String -> Value
forall a. ToValue a => a -> Value
value (String -> Value) -> (Int8 -> String) -> Int8 -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int8 -> String
forall a. Show a => a -> String
show
{-# INLINE value #-}
instance ToValue Int16 where
value :: Int16 -> Value
value = String -> Value
forall a. ToValue a => a -> Value
value (String -> Value) -> (Int16 -> String) -> Int16 -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int16 -> String
forall a. Show a => a -> String
show
{-# INLINE value #-}
instance ToValue Int32 where
value :: Int32 -> Value
value = String -> Value
forall a. ToValue a => a -> Value
value (String -> Value) -> (Int32 -> String) -> Int32 -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int32 -> String
forall a. Show a => a -> String
show
{-# INLINE value #-}
instance ToValue Int64 where
value :: Int64 -> Value
value = String -> Value
forall a. ToValue a => a -> Value
value (String -> Value) -> (Int64 -> String) -> Int64 -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int64 -> String
forall a. Show a => a -> String
show
{-# INLINE value #-}
instance ToValue Word where
value :: Word -> Value
value = String -> Value
forall a. ToValue a => a -> Value
value (String -> Value) -> (Word -> String) -> Word -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> String
forall a. Show a => a -> String
show
{-# INLINE value #-}
instance ToValue Word8 where
value :: Word8 -> Value
value = String -> Value
forall a. ToValue a => a -> Value
value (String -> Value) -> (Word8 -> String) -> Word8 -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word8 -> String
forall a. Show a => a -> String
show
{-# INLINE value #-}
instance ToValue Word16 where
value :: Word16 -> Value
value = String -> Value
forall a. ToValue a => a -> Value
value (String -> Value) -> (Word16 -> String) -> Word16 -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word16 -> String
forall a. Show a => a -> String
show
{-# INLINE value #-}
instance ToValue Word32 where
value :: Word32 -> Value
value = String -> Value
forall a. ToValue a => a -> Value
value (String -> Value) -> (Word32 -> String) -> Word32 -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word32 -> String
forall a. Show a => a -> String
show
{-# INLINE value #-}
instance ToValue Word64 where
value :: Word64 -> Value
value = String -> Value
forall a. ToValue a => a -> Value
value (String -> Value) -> (Word64 -> String) -> Word64 -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word64 -> String
forall a. Show a => a -> String
show
{-# INLINE value #-}
instance ToValue Integer where
value :: Integer -> Value
value = String -> Value
forall a. ToValue a => a -> Value
value (String -> Value) -> (Integer -> String) -> Integer -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> String
forall a. Show a => a -> String
show
{-# INLINE value #-}
instance ToValue Natural where
value :: Natural -> Value
value = String -> Value
forall a. ToValue a => a -> Value
value (String -> Value) -> (Natural -> String) -> Natural -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Natural -> String
forall a. Show a => a -> String
show
{-# INLINE value #-}
instance ToValue Float where
value :: Float -> Value
value = String -> Value
forall a. ToValue a => a -> Value
value (String -> Value) -> (Float -> String) -> Float -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Float -> String
forall a. Show a => a -> String
show
{-# INLINE value #-}
instance ToValue Double where
value :: Double -> Value
value = String -> Value
forall a. ToValue a => a -> Value
value (String -> Value) -> (Double -> String) -> Double -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> String
forall a. Show a => a -> String
show
{-# INLINE value #-}
instance (Fixed.HasResolution a) => ToValue (Fixed.Fixed a) where
value :: Fixed a -> Value
value = String -> Value
forall a. ToValue a => a -> Value
value (String -> Value) -> (Fixed a -> String) -> Fixed a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Fixed a -> String
forall {k} (a :: k). HasResolution a => Bool -> Fixed a -> String
Fixed.showFixed Bool
True
{-# INLINE value #-}
instance ToValue Time.CalendarDiffDays where
value :: CalendarDiffDays -> Value
value = String -> Value
forall a. ToValue a => a -> Value
value (String -> Value)
-> (CalendarDiffDays -> String) -> CalendarDiffDays -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CalendarDiffDays -> String
forall t. ISO8601 t => t -> String
Time.iso8601Show
{-# INLINE value #-}
instance ToValue Time.CalendarDiffTime where
value :: CalendarDiffTime -> Value
value = String -> Value
forall a. ToValue a => a -> Value
value (String -> Value)
-> (CalendarDiffTime -> String) -> CalendarDiffTime -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CalendarDiffTime -> String
forall t. ISO8601 t => t -> String
Time.iso8601Show
{-# INLINE value #-}
instance ToValue Time.Day where
value :: Day -> Value
value = String -> Value
forall a. ToValue a => a -> Value
value (String -> Value) -> (Day -> String) -> Day -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Day -> String
forall t. ISO8601 t => t -> String
Time.iso8601Show
{-# INLINE value #-}
instance ToValue Time.TimeZone where
value :: TimeZone -> Value
value = String -> Value
forall a. ToValue a => a -> Value
value (String -> Value) -> (TimeZone -> String) -> TimeZone -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeZone -> String
forall t. ISO8601 t => t -> String
Time.iso8601Show
{-# INLINE value #-}
instance ToValue Time.TimeOfDay where
value :: TimeOfDay -> Value
value = String -> Value
forall a. ToValue a => a -> Value
value (String -> Value) -> (TimeOfDay -> String) -> TimeOfDay -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeOfDay -> String
forall t. ISO8601 t => t -> String
Time.iso8601Show
{-# INLINE value #-}
instance ToValue Time.LocalTime where
value :: LocalTime -> Value
value = String -> Value
forall a. ToValue a => a -> Value
value (String -> Value) -> (LocalTime -> String) -> LocalTime -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LocalTime -> String
forall t. ISO8601 t => t -> String
Time.iso8601Show
{-# INLINE value #-}
instance ToValue Time.ZonedTime where
value :: ZonedTime -> Value
value = String -> Value
forall a. ToValue a => a -> Value
value (String -> Value) -> (ZonedTime -> String) -> ZonedTime -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ZonedTime -> String
forall t. ISO8601 t => t -> String
Time.iso8601Show
{-# INLINE value #-}
instance ToValue Time.NominalDiffTime where
value :: NominalDiffTime -> Value
value = String -> Value
forall a. ToValue a => a -> Value
value (String -> Value)
-> (NominalDiffTime -> String) -> NominalDiffTime -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NominalDiffTime -> String
forall a. Show a => a -> String
show
{-# INLINE value #-}
instance ToValue Time.DiffTime where
value :: DiffTime -> Value
value = String -> Value
forall a. ToValue a => a -> Value
value (String -> Value) -> (DiffTime -> String) -> DiffTime -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DiffTime -> String
forall a. Show a => a -> String
show
{-# INLINE value #-}
instance ToValue Time.DayOfWeek where
value :: DayOfWeek -> Value
value = \DayOfWeek
x -> case DayOfWeek
x of
DayOfWeek
Time.Monday -> Value
"monday"
DayOfWeek
Time.Tuesday -> Value
"tuesday"
DayOfWeek
Time.Wednesday -> Value
"wednesday"
DayOfWeek
Time.Thursday -> Value
"thursday"
DayOfWeek
Time.Friday -> Value
"friday"
DayOfWeek
Time.Saturday -> Value
"saturday"
DayOfWeek
Time.Sunday -> Value
"sunday"
data Path
= Push !Segment
| Attr !Key !Value
deriving (Path -> Path -> Bool
(Path -> Path -> Bool) -> (Path -> Path -> Bool) -> Eq Path
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Path -> Path -> Bool
== :: Path -> Path -> Bool
$c/= :: Path -> Path -> Bool
/= :: Path -> Path -> Bool
Eq, Int -> Path -> ShowS
[Path] -> ShowS
Path -> String
(Int -> Path -> ShowS)
-> (Path -> String) -> ([Path] -> ShowS) -> Show Path
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Path -> ShowS
showsPrec :: Int -> Path -> ShowS
$cshow :: Path -> String
show :: Path -> String
$cshowList :: [Path] -> ShowS
showList :: [Path] -> ShowS
Show)
class ToPath a where
path :: a -> Seq.Seq Path
instance ToPath (Seq.Seq Path) where
path :: Seq Path -> Seq Path
path = Seq Path -> Seq Path
forall a. a -> a
id
{-# INLINE path #-}
instance {-# OVERLAPPABLE #-} (Foldable f) => ToPath (f Path) where
path :: f Path -> Seq Path
path = [Path] -> Seq Path
forall a. [a] -> Seq a
Seq.fromList ([Path] -> Seq Path) -> (f Path -> [Path]) -> f Path -> Seq Path
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f Path -> [Path]
forall a. f a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList
{-# INLINE path #-}