{-# LANGUAGE UndecidableInstances #-}
module Effectful.Notify.Internal.Data.Note
( Note,
mkNote,
setBody,
getBody,
setSummary,
getSummary,
setTimeout,
getTimeout,
setTitle,
getTitle,
setUrgency,
getUrgency,
)
where
import Control.DeepSeq (NFData)
import Data.Text (Text)
import Effectful.Notify.Internal.Data.NotifyTimeout (NotifyTimeout)
import Effectful.Notify.Internal.Data.NotifyUrgency (NotifyUrgency)
import GHC.Generics (Generic)
import GHC.Records (HasField (getField))
import GHC.Show (appPrec1)
import Optics.Core (A_Lens, LabelOptic (labelOptic), (^.))
import Optics.Core qualified as O
data Note
= MkNoteInternal
(Maybe Text)
Text
(Maybe NotifyTimeout)
(Maybe Text)
(Maybe NotifyUrgency)
deriving stock (Note -> Note -> Bool
(Note -> Note -> Bool) -> (Note -> Note -> Bool) -> Eq Note
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Note -> Note -> Bool
== :: Note -> Note -> Bool
$c/= :: Note -> Note -> Bool
/= :: Note -> Note -> Bool
Eq, (forall x. Note -> Rep Note x)
-> (forall x. Rep Note x -> Note) -> Generic Note
forall x. Rep Note x -> Note
forall x. Note -> Rep Note x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Note -> Rep Note x
from :: forall x. Note -> Rep Note x
$cto :: forall x. Rep Note x -> Note
to :: forall x. Rep Note x -> Note
Generic, Eq Note
Eq Note =>
(Note -> Note -> Ordering)
-> (Note -> Note -> Bool)
-> (Note -> Note -> Bool)
-> (Note -> Note -> Bool)
-> (Note -> Note -> Bool)
-> (Note -> Note -> Note)
-> (Note -> Note -> Note)
-> Ord Note
Note -> Note -> Bool
Note -> Note -> Ordering
Note -> Note -> Note
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
$ccompare :: Note -> Note -> Ordering
compare :: Note -> Note -> Ordering
$c< :: Note -> Note -> Bool
< :: Note -> Note -> Bool
$c<= :: Note -> Note -> Bool
<= :: Note -> Note -> Bool
$c> :: Note -> Note -> Bool
> :: Note -> Note -> Bool
$c>= :: Note -> Note -> Bool
>= :: Note -> Note -> Bool
$cmax :: Note -> Note -> Note
max :: Note -> Note -> Note
$cmin :: Note -> Note -> Note
min :: Note -> Note -> Note
Ord)
deriving anyclass (Note -> ()
(Note -> ()) -> NFData Note
forall a. (a -> ()) -> NFData a
$crnf :: Note -> ()
rnf :: Note -> ()
NFData)
instance Show Note where
showsPrec :: Int -> Note -> ShowS
showsPrec Int
i Note
note =
Bool -> ShowS -> ShowS
showParen
(Int
i Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
appPrec1)
( String -> ShowS
showString String
"MkNote {body = "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Maybe Text -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
i (Note
note Note -> Optic' A_Lens NoIx Note (Maybe Text) -> Maybe Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx Note (Maybe Text)
#body)
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
", summary = "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Text -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
i (Note
note Note -> Optic' A_Lens NoIx Note Text -> Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx Note Text
#summary)
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
", timeout = "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Maybe NotifyTimeout -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
i (Note
note Note
-> Optic' A_Lens NoIx Note (Maybe NotifyTimeout)
-> Maybe NotifyTimeout
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx Note (Maybe NotifyTimeout)
#timeout)
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
", title = "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Maybe Text -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
i (Note
note Note -> Optic' A_Lens NoIx Note (Maybe Text) -> Maybe Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx Note (Maybe Text)
#title)
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
", urgency = "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Maybe NotifyUrgency -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
i (Note
note Note
-> Optic' A_Lens NoIx Note (Maybe NotifyUrgency)
-> Maybe NotifyUrgency
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx Note (Maybe NotifyUrgency)
#urgency)
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
"}"
)
instance HasField "body" Note (Maybe Text) where
getField :: Note -> Maybe Text
getField (MkNoteInternal Maybe Text
a Text
_ Maybe NotifyTimeout
_ Maybe Text
_ Maybe NotifyUrgency
_) = Maybe Text
a
instance HasField "summary" Note Text where
getField :: Note -> Text
getField (MkNoteInternal Maybe Text
_ Text
a Maybe NotifyTimeout
_ Maybe Text
_ Maybe NotifyUrgency
_) = Text
a
instance HasField "timeout" Note (Maybe NotifyTimeout) where
getField :: Note -> Maybe NotifyTimeout
getField (MkNoteInternal Maybe Text
_ Text
_ Maybe NotifyTimeout
a Maybe Text
_ Maybe NotifyUrgency
_) = Maybe NotifyTimeout
a
instance HasField "title" Note (Maybe Text) where
getField :: Note -> Maybe Text
getField (MkNoteInternal Maybe Text
_ Text
_ Maybe NotifyTimeout
_ Maybe Text
a Maybe NotifyUrgency
_) = Maybe Text
a
instance HasField "urgency" Note (Maybe NotifyUrgency) where
getField :: Note -> Maybe NotifyUrgency
getField (MkNoteInternal Maybe Text
_ Text
_ Maybe NotifyTimeout
_ Maybe Text
_ Maybe NotifyUrgency
a) = Maybe NotifyUrgency
a
instance
(k ~ A_Lens, a ~ Maybe Text, b ~ Maybe Text) =>
LabelOptic "body" k Note Note a b
where
labelOptic :: Optic k NoIx Note Note a b
labelOptic = LensVL Note Note a b -> Lens Note Note a b
forall s t a b. LensVL s t a b -> Lens s t a b
O.lensVL (LensVL Note Note a b -> Lens Note Note a b)
-> LensVL Note Note a b -> Lens Note Note a b
forall a b. (a -> b) -> a -> b
$ \a -> f b
f (MkNoteInternal Maybe Text
a1 Text
a2 Maybe NotifyTimeout
a3 Maybe Text
a4 Maybe NotifyUrgency
a5) ->
(Maybe Text -> Note) -> f (Maybe Text) -> f Note
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Maybe Text
b -> Maybe Text
-> Text
-> Maybe NotifyTimeout
-> Maybe Text
-> Maybe NotifyUrgency
-> Note
MkNoteInternal Maybe Text
b Text
a2 Maybe NotifyTimeout
a3 Maybe Text
a4 Maybe NotifyUrgency
a5) (a -> f b
f a
Maybe Text
a1)
{-# INLINE labelOptic #-}
instance
(k ~ A_Lens, a ~ Text, b ~ Text) =>
LabelOptic "summary" k Note Note a b
where
labelOptic :: Optic k NoIx Note Note a b
labelOptic = LensVL Note Note a b -> Lens Note Note a b
forall s t a b. LensVL s t a b -> Lens s t a b
O.lensVL (LensVL Note Note a b -> Lens Note Note a b)
-> LensVL Note Note a b -> Lens Note Note a b
forall a b. (a -> b) -> a -> b
$ \a -> f b
f (MkNoteInternal Maybe Text
a1 Text
a2 Maybe NotifyTimeout
a3 Maybe Text
a4 Maybe NotifyUrgency
a5) ->
(Text -> Note) -> f Text -> f Note
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Text
b -> Maybe Text
-> Text
-> Maybe NotifyTimeout
-> Maybe Text
-> Maybe NotifyUrgency
-> Note
MkNoteInternal Maybe Text
a1 Text
b Maybe NotifyTimeout
a3 Maybe Text
a4 Maybe NotifyUrgency
a5) (a -> f b
f a
Text
a2)
{-# INLINE labelOptic #-}
instance
(k ~ A_Lens, a ~ Maybe NotifyTimeout, b ~ Maybe NotifyTimeout) =>
LabelOptic "timeout" k Note Note a b
where
labelOptic :: Optic k NoIx Note Note a b
labelOptic = LensVL Note Note a b -> Lens Note Note a b
forall s t a b. LensVL s t a b -> Lens s t a b
O.lensVL (LensVL Note Note a b -> Lens Note Note a b)
-> LensVL Note Note a b -> Lens Note Note a b
forall a b. (a -> b) -> a -> b
$ \a -> f b
f (MkNoteInternal Maybe Text
a1 Text
a2 Maybe NotifyTimeout
a3 Maybe Text
a4 Maybe NotifyUrgency
a5) ->
(Maybe NotifyTimeout -> Note) -> f (Maybe NotifyTimeout) -> f Note
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Maybe NotifyTimeout
b -> Maybe Text
-> Text
-> Maybe NotifyTimeout
-> Maybe Text
-> Maybe NotifyUrgency
-> Note
MkNoteInternal Maybe Text
a1 Text
a2 Maybe NotifyTimeout
b Maybe Text
a4 Maybe NotifyUrgency
a5) (a -> f b
f a
Maybe NotifyTimeout
a3)
{-# INLINE labelOptic #-}
instance
(k ~ A_Lens, a ~ Maybe Text, b ~ Maybe Text) =>
LabelOptic "title" k Note Note a b
where
labelOptic :: Optic k NoIx Note Note a b
labelOptic = LensVL Note Note a b -> Lens Note Note a b
forall s t a b. LensVL s t a b -> Lens s t a b
O.lensVL (LensVL Note Note a b -> Lens Note Note a b)
-> LensVL Note Note a b -> Lens Note Note a b
forall a b. (a -> b) -> a -> b
$ \a -> f b
f (MkNoteInternal Maybe Text
a1 Text
a2 Maybe NotifyTimeout
a3 Maybe Text
a4 Maybe NotifyUrgency
a5) ->
(Maybe Text -> Note) -> f (Maybe Text) -> f Note
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Maybe Text
b -> Maybe Text
-> Text
-> Maybe NotifyTimeout
-> Maybe Text
-> Maybe NotifyUrgency
-> Note
MkNoteInternal Maybe Text
a1 Text
a2 Maybe NotifyTimeout
a3 Maybe Text
b Maybe NotifyUrgency
a5) (a -> f b
f a
Maybe Text
a4)
{-# INLINE labelOptic #-}
instance
(k ~ A_Lens, a ~ Maybe NotifyUrgency, b ~ Maybe NotifyUrgency) =>
LabelOptic "urgency" k Note Note a b
where
labelOptic :: Optic k NoIx Note Note a b
labelOptic = LensVL Note Note a b -> Lens Note Note a b
forall s t a b. LensVL s t a b -> Lens s t a b
O.lensVL (LensVL Note Note a b -> Lens Note Note a b)
-> LensVL Note Note a b -> Lens Note Note a b
forall a b. (a -> b) -> a -> b
$ \a -> f b
f (MkNoteInternal Maybe Text
a1 Text
a2 Maybe NotifyTimeout
a3 Maybe Text
a4 Maybe NotifyUrgency
a5) ->
(Maybe NotifyUrgency -> Note) -> f (Maybe NotifyUrgency) -> f Note
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Maybe NotifyUrgency
b -> Maybe Text
-> Text
-> Maybe NotifyTimeout
-> Maybe Text
-> Maybe NotifyUrgency
-> Note
MkNoteInternal Maybe Text
a1 Text
a2 Maybe NotifyTimeout
a3 Maybe Text
a4 Maybe NotifyUrgency
b) (a -> f b
f a
Maybe NotifyUrgency
a5)
{-# INLINE labelOptic #-}
mkNote :: Text -> Note
mkNote :: Text -> Note
mkNote Text
summary = Maybe Text
-> Text
-> Maybe NotifyTimeout
-> Maybe Text
-> Maybe NotifyUrgency
-> Note
MkNoteInternal Maybe Text
forall a. Maybe a
Nothing Text
summary Maybe NotifyTimeout
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing Maybe NotifyUrgency
forall a. Maybe a
Nothing
setBody :: Maybe Text -> Note -> Note
setBody :: Maybe Text -> Note -> Note
setBody = Optic' A_Lens NoIx Note (Maybe Text) -> Maybe Text -> Note -> Note
forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> b -> s -> t
O.set' Optic' A_Lens NoIx Note (Maybe Text)
#body
getBody :: Note -> Maybe Text
getBody :: Note -> Maybe Text
getBody = Optic' A_Lens NoIx Note (Maybe Text) -> Note -> Maybe Text
forall k (is :: IxList) s a.
Is k A_Getter =>
Optic' k is s a -> s -> a
O.view Optic' A_Lens NoIx Note (Maybe Text)
#body
setSummary :: Text -> Note -> Note
setSummary :: Text -> Note -> Note
setSummary = Optic' A_Lens NoIx Note Text -> Text -> Note -> Note
forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> b -> s -> t
O.set' Optic' A_Lens NoIx Note Text
#summary
getSummary :: Note -> Text
getSummary :: Note -> Text
getSummary = Optic' A_Lens NoIx Note Text -> Note -> Text
forall k (is :: IxList) s a.
Is k A_Getter =>
Optic' k is s a -> s -> a
O.view Optic' A_Lens NoIx Note Text
#summary
setTimeout :: Maybe NotifyTimeout -> Note -> Note
setTimeout :: Maybe NotifyTimeout -> Note -> Note
setTimeout = Optic' A_Lens NoIx Note (Maybe NotifyTimeout)
-> Maybe NotifyTimeout -> Note -> Note
forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> b -> s -> t
O.set' Optic' A_Lens NoIx Note (Maybe NotifyTimeout)
#timeout
getTimeout :: Note -> Maybe NotifyTimeout
getTimeout :: Note -> Maybe NotifyTimeout
getTimeout = Optic' A_Lens NoIx Note (Maybe NotifyTimeout)
-> Note -> Maybe NotifyTimeout
forall k (is :: IxList) s a.
Is k A_Getter =>
Optic' k is s a -> s -> a
O.view Optic' A_Lens NoIx Note (Maybe NotifyTimeout)
#timeout
setTitle :: Maybe Text -> Note -> Note
setTitle :: Maybe Text -> Note -> Note
setTitle = Optic' A_Lens NoIx Note (Maybe Text) -> Maybe Text -> Note -> Note
forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> b -> s -> t
O.set' Optic' A_Lens NoIx Note (Maybe Text)
#title
getTitle :: Note -> Maybe Text
getTitle :: Note -> Maybe Text
getTitle = Optic' A_Lens NoIx Note (Maybe Text) -> Note -> Maybe Text
forall k (is :: IxList) s a.
Is k A_Getter =>
Optic' k is s a -> s -> a
O.view Optic' A_Lens NoIx Note (Maybe Text)
#title
setUrgency :: Maybe NotifyUrgency -> Note -> Note
setUrgency :: Maybe NotifyUrgency -> Note -> Note
setUrgency = Optic' A_Lens NoIx Note (Maybe NotifyUrgency)
-> Maybe NotifyUrgency -> Note -> Note
forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> b -> s -> t
O.set' Optic' A_Lens NoIx Note (Maybe NotifyUrgency)
#urgency
getUrgency :: Note -> Maybe NotifyUrgency
getUrgency :: Note -> Maybe NotifyUrgency
getUrgency = Optic' A_Lens NoIx Note (Maybe NotifyUrgency)
-> Note -> Maybe NotifyUrgency
forall k (is :: IxList) s a.
Is k A_Getter =>
Optic' k is s a -> s -> a
O.view Optic' A_Lens NoIx Note (Maybe NotifyUrgency)
#urgency