{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE NoRebindableSyntax #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilies #-}
module Duckling.Email.Types where
import Control.DeepSeq
import Data.Aeson
import Data.Hashable
import Data.Text (Text)
import GHC.Generics
import Prelude
import Duckling.Resolve (Resolve(..))
newtype EmailData = EmailData { EmailData -> Text
value :: Text }
deriving (EmailData -> EmailData -> Bool
(EmailData -> EmailData -> Bool)
-> (EmailData -> EmailData -> Bool) -> Eq EmailData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EmailData -> EmailData -> Bool
$c/= :: EmailData -> EmailData -> Bool
== :: EmailData -> EmailData -> Bool
$c== :: EmailData -> EmailData -> Bool
Eq, (forall x. EmailData -> Rep EmailData x)
-> (forall x. Rep EmailData x -> EmailData) -> Generic EmailData
forall x. Rep EmailData x -> EmailData
forall x. EmailData -> Rep EmailData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EmailData x -> EmailData
$cfrom :: forall x. EmailData -> Rep EmailData x
Generic, Int -> EmailData -> Int
EmailData -> Int
(Int -> EmailData -> Int)
-> (EmailData -> Int) -> Hashable EmailData
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: EmailData -> Int
$chash :: EmailData -> Int
hashWithSalt :: Int -> EmailData -> Int
$chashWithSalt :: Int -> EmailData -> Int
Hashable, Eq EmailData
Eq EmailData
-> (EmailData -> EmailData -> Ordering)
-> (EmailData -> EmailData -> Bool)
-> (EmailData -> EmailData -> Bool)
-> (EmailData -> EmailData -> Bool)
-> (EmailData -> EmailData -> Bool)
-> (EmailData -> EmailData -> EmailData)
-> (EmailData -> EmailData -> EmailData)
-> Ord EmailData
EmailData -> EmailData -> Bool
EmailData -> EmailData -> Ordering
EmailData -> EmailData -> EmailData
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: EmailData -> EmailData -> EmailData
$cmin :: EmailData -> EmailData -> EmailData
max :: EmailData -> EmailData -> EmailData
$cmax :: EmailData -> EmailData -> EmailData
>= :: EmailData -> EmailData -> Bool
$c>= :: EmailData -> EmailData -> Bool
> :: EmailData -> EmailData -> Bool
$c> :: EmailData -> EmailData -> Bool
<= :: EmailData -> EmailData -> Bool
$c<= :: EmailData -> EmailData -> Bool
< :: EmailData -> EmailData -> Bool
$c< :: EmailData -> EmailData -> Bool
compare :: EmailData -> EmailData -> Ordering
$ccompare :: EmailData -> EmailData -> Ordering
$cp1Ord :: Eq EmailData
Ord, Int -> EmailData -> ShowS
[EmailData] -> ShowS
EmailData -> String
(Int -> EmailData -> ShowS)
-> (EmailData -> String)
-> ([EmailData] -> ShowS)
-> Show EmailData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EmailData] -> ShowS
$cshowList :: [EmailData] -> ShowS
show :: EmailData -> String
$cshow :: EmailData -> String
showsPrec :: Int -> EmailData -> ShowS
$cshowsPrec :: Int -> EmailData -> ShowS
Show, EmailData -> ()
(EmailData -> ()) -> NFData EmailData
forall a. (a -> ()) -> NFData a
rnf :: EmailData -> ()
$crnf :: EmailData -> ()
NFData)
instance Resolve EmailData where
type ResolvedValue EmailData = EmailData
resolve :: Context
-> Options -> EmailData -> Maybe (ResolvedValue EmailData, Bool)
resolve Context
_ Options
_ EmailData
x = (EmailData, Bool) -> Maybe (EmailData, Bool)
forall a. a -> Maybe a
Just (EmailData
x, Bool
False)
instance ToJSON EmailData where
toJSON :: EmailData -> Value
toJSON EmailData {Text
value :: Text
value :: EmailData -> Text
value} = [Pair] -> Value
object
[ Text
"value" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
value
, Text
"type" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= (Text
"value" :: Text)
]