| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Effectful.Notify.Static
Description
Provides an effect for desktop notifications.
Since: 0.1
Synopsis
- data Notify (a :: Type -> Type) b
- initNotifyEnv :: forall (es :: [Effect]). (HasCallStack, Notify :> es) => NotifySystemOs -> Eff es NotifyEnv
- notify :: forall (es :: [Effect]). (HasCallStack, Notify :> es) => NotifyEnv -> Note -> Eff es ()
- runNotify :: forall (es :: [Effect]) a. (HasCallStack, IOE :> es) => Eff (Notify ': es) a -> Eff es a
- newtype NotifyInitException = MkNotifyInitException {}
- data NotifyException = MkNotifyException {
- exception :: SomeException
- fatal :: Bool
- note :: Note
- notifySystem :: NotifySystem
- catchNonFatalNotify :: forall (es :: [Effect]). (HasCallStack, Notify :> es) => NotifyEnv -> Note -> (NotifyException -> Eff es ()) -> Eff es ()
- tryNonFatalNotify :: forall (es :: [Effect]). (HasCallStack, Notify :> es) => NotifyEnv -> Note -> Eff es (Maybe NotifyException)
- tryNonFatalNotify_ :: forall (es :: [Effect]). (HasCallStack, Notify :> es) => NotifyEnv -> Note -> Eff es ()
- data NotifySystemOs
- defaultNotifySystemOs :: NotifySystemOs
- data NotifySystem
- defaultNotifySystem :: NotifySystem
- notifySystemToOs :: NotifySystem -> Either NotifyParseException NotifySystemOs
- notifySystemFromOs :: NotifySystemOs -> NotifySystem
- data Os
- data NotifyParseException = MkNotifyParseException {
- os :: Os
- system :: NotifySystem
- data NotifyEnv
- notifyEnvToSystemOs :: NotifyEnv -> NotifySystemOs
- data Note
- mkNote :: Text -> Note
- setBody :: Maybe Text -> Note -> Note
- getBody :: Note -> Maybe Text
- setSummary :: Text -> Note -> Note
- getSummary :: Note -> Text
- setTimeout :: Maybe NotifyTimeout -> Note -> Note
- getTimeout :: Note -> Maybe NotifyTimeout
- setTitle :: Maybe Text -> Note -> Note
- getTitle :: Note -> Maybe Text
- setUrgency :: Maybe NotifyUrgency -> Note -> Note
- getUrgency :: Note -> Maybe NotifyUrgency
- data NotifyTimeout
- _NotifyTimeoutMillis :: Prism' NotifyTimeout Int
- _NotifyTimeoutNever :: Prism' NotifyTimeout ()
- data NotifyUrgency
- _NotifyUrgencyLow :: Prism' NotifyUrgency ()
- _NotifyUrgencyNormal :: Prism' NotifyUrgency ()
- _NotifyUrgencyCritical :: Prism' NotifyUrgency ()
Description
notify-effectful is a library for implementing cross-platform desktop
notifications. Currently supports:
- Linux: Supports
dbusandnotify-send. That is, if there is a running dbus notification server, it can be used directly.notify-send (libnotify)can also be used, though it also requires a running dbus server. - Osx: Supports built-in
apple-scripti.e.osascript. - Windows: Unsupported. Functions are mere stubs that will compile (with a warning) and do nothing at runtime.
Usage
General usage involves choosing the notification system and using that to initialize the environment:
-- choose system let systemOs ::NotifySystemOssystemOs = ... -- prepare environment notifyEnv <-initNotifyEnvsystemOs -- send notification let note =mkNote"A summary" &setBody"Some notification" &setTitle"My Application"notifynotifyEnv note
Choosing the system is more interesting. If we do not care about being
cross-platform, we can simply choose a NotifySystemOs directly
and pass it to init:
-- The NotifySystemOsDBus constructor is only available on linux. let systemOs ::NotifySystemOssystemOs = NotifySystemOsDBus notifyEnv <-initNotifyEnvsystemOs ...
If we need to work on several platforms, we can instead use NotifySystem,
which includes every possible notification system and is available on all
platforms. We then pass it to notifySystemToOs, which -- if successful --
will return the NotifySystemOs and we can continue as normal.
-- All NotifySystem constructors are available on all platforms. let system ::NotifySystemsystem = ... systemOs <-notifySystemToOssystem >>= \case Left ex -> throwM ex Right s -> pure s notifyEnv <-initNotifyEnvsystemOs ...
If a system is chosen that is unavailable on the current platform,
a NotifyParseException will be returned.
Effect
data Notify (a :: Type -> Type) b Source #
Static notify effect.
Since: 0.1
Instances
| type DispatchOf Notify Source # | |
Defined in Effectful.Notify.Static | |
| data StaticRep Notify Source # | |
Defined in Effectful.Notify.Static | |
Arguments
| :: forall (es :: [Effect]). (HasCallStack, Notify :> es) | |
| => NotifySystemOs | System. |
| -> Eff es NotifyEnv |
Initialize the notification environment.
Since: 0.1
Arguments
| :: forall (es :: [Effect]). (HasCallStack, Notify :> es) | |
| => NotifyEnv | Env. |
| -> Note | Note. |
| -> Eff es () |
Send a notification.
Since: 0.1
Handlers
runNotify :: forall (es :: [Effect]) a. (HasCallStack, IOE :> es) => Eff (Notify ': es) a -> Eff es a Source #
Runs a Notify effect in IO.
Since: 0.1
Errors
newtype NotifyInitException Source #
Exceptions thrown when initializing notifications.
Since: 0.1
Constructors
| MkNotifyInitException | |
Fields | |
Instances
| Exception NotifyInitException Source # | Since: 0.1 |
| Show NotifyInitException Source # | Since: 0.1 |
Defined in Effectful.Notify.Internal.Data.NotifyInitException Methods showsPrec :: Int -> NotifyInitException -> ShowS # show :: NotifyInitException -> String # showList :: [NotifyInitException] -> ShowS # | |
data NotifyException Source #
Exceptions thrown when sending notifications. The list of non-fatal exceptions includes:
- DBus: Non-fatal client errors.
All others are considered fatal.
Since: 0.1
Constructors
| MkNotifyException | |
Fields
| |
Instances
Arguments
| :: forall (es :: [Effect]). (HasCallStack, Notify :> es) | |
| => NotifyEnv | Env. |
| -> Note | Note. |
| -> (NotifyException -> Eff es ()) | Handler. |
| -> Eff es () |
Runs notify and runs the handler on any non-fatal NotifyExceptions.
Any other exceptions are rethrown.
Since: 0.1
Arguments
| :: forall (es :: [Effect]). (HasCallStack, Notify :> es) | |
| => NotifyEnv | Env. |
| -> Note | Note. |
| -> Eff es (Maybe NotifyException) |
Like notify, but catches non-fatal NotifyException.
Since: 0.1
Arguments
| :: forall (es :: [Effect]). (HasCallStack, Notify :> es) | |
| => NotifyEnv | Env. |
| -> Note | Note. |
| -> Eff es () |
Like tryNonFatalNotify, but catches and discards the exception.
Since: 0.1
Types
System
Platform-specific
data NotifySystemOs Source #
Notification system. Options are platform specific.
Since: 0.1
Constructors
| NotifySystemOsDBus | |
| NotifySystemOsNotifySend |
Instances
defaultNotifySystemOs :: NotifySystemOs Source #
Since: 0.1
All platforms
data NotifySystem Source #
Represents all possible notification systems. This is useful for when we want to choose the system in some way that works across multiple platforms without requiring cpp.
Since: 0.1
Instances
| NFData NotifySystem Source # | |||||
Defined in Effectful.Notify.Internal.Data.NotifySystem Methods rnf :: NotifySystem -> () # | |||||
| Bounded NotifySystem Source # | |||||
Defined in Effectful.Notify.Internal.Data.NotifySystem | |||||
| Enum NotifySystem Source # | |||||
Defined in Effectful.Notify.Internal.Data.NotifySystem Methods succ :: NotifySystem -> NotifySystem # pred :: NotifySystem -> NotifySystem # toEnum :: Int -> NotifySystem # fromEnum :: NotifySystem -> Int # enumFrom :: NotifySystem -> [NotifySystem] # enumFromThen :: NotifySystem -> NotifySystem -> [NotifySystem] # enumFromTo :: NotifySystem -> NotifySystem -> [NotifySystem] # enumFromThenTo :: NotifySystem -> NotifySystem -> NotifySystem -> [NotifySystem] # | |||||
| Generic NotifySystem Source # | |||||
Defined in Effectful.Notify.Internal.Data.NotifySystem Associated Types
| |||||
| Show NotifySystem Source # | |||||
Defined in Effectful.Notify.Internal.Data.NotifySystem Methods showsPrec :: Int -> NotifySystem -> ShowS # show :: NotifySystem -> String # showList :: [NotifySystem] -> ShowS # | |||||
| Eq NotifySystem Source # | |||||
Defined in Effectful.Notify.Internal.Data.NotifySystem | |||||
| Ord NotifySystem Source # | |||||
Defined in Effectful.Notify.Internal.Data.NotifySystem Methods compare :: NotifySystem -> NotifySystem -> Ordering # (<) :: NotifySystem -> NotifySystem -> Bool # (<=) :: NotifySystem -> NotifySystem -> Bool # (>) :: NotifySystem -> NotifySystem -> Bool # (>=) :: NotifySystem -> NotifySystem -> Bool # max :: NotifySystem -> NotifySystem -> NotifySystem # min :: NotifySystem -> NotifySystem -> NotifySystem # | |||||
| Display NotifySystem Source # | Since: 0.1 | ||||
Defined in Effectful.Notify.Internal.Data.NotifySystem Methods displayBuilder :: NotifySystem -> Builder Source # displayList :: [NotifySystem] -> Builder Source # displayPrec :: Int -> NotifySystem -> Builder Source # | |||||
| type Rep NotifySystem Source # | |||||
Defined in Effectful.Notify.Internal.Data.NotifySystem type Rep NotifySystem = D1 ('MetaData "NotifySystem" "Effectful.Notify.Internal.Data.NotifySystem" "notify-effectful-0.1-inplace" 'False) ((C1 ('MetaCons "NotifySystemAppleScript" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NotifySystemDBus" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "NotifySystemNotifySend" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NotifySystemWindows" 'PrefixI 'False) (U1 :: Type -> Type))) | |||||
defaultNotifySystem :: NotifySystem Source #
Since: 0.1
notifySystemToOs :: NotifySystem -> Either NotifyParseException NotifySystemOs Source #
Converts platform-agnostic NotifySystem to platform-specific
NotifySystemOs. Useful for obtaining a valid system for the current
platform without cpp.
Since: 0.1
notifySystemFromOs :: NotifySystemOs -> NotifySystem Source #
Inverse notifySystemToOs.
Since: 0.1
Os types.
Since: 0.1
data NotifyParseException Source #
Exceptions thrown when parsing NotifySystem to NotifySystemOs.
Since: 0.1
Constructors
| MkNotifyParseException | |
Fields
| |
Instances
| Exception NotifyParseException Source # | Since: 0.1 |
Defined in Effectful.Notify.Internal.Data.NotifySystem | |
| Show NotifyParseException Source # | |
Defined in Effectful.Notify.Internal.Data.NotifySystem Methods showsPrec :: Int -> NotifyParseException -> ShowS # show :: NotifyParseException -> String # showList :: [NotifyParseException] -> ShowS # | |
| (k ~ A_Lens, a ~ Os, b ~ Os) => LabelOptic "os" k NotifyParseException NotifyParseException a b Source # | Since: 0.1 |
Defined in Effectful.Notify.Internal.Data.NotifySystem Methods labelOptic :: Optic k NoIx NotifyParseException NotifyParseException a b Source # | |
| (k ~ A_Lens, a ~ NotifySystem, b ~ NotifySystem) => LabelOptic "system" k NotifyParseException NotifyParseException a b Source # | Since: 0.1 |
Defined in Effectful.Notify.Internal.Data.NotifySystem Methods labelOptic :: Optic k NoIx NotifyParseException NotifyParseException a b Source # | |
Env
Notification environment.
Since: 0.1
notifyEnvToSystemOs :: NotifyEnv -> NotifySystemOs Source #
Gives the system for the given environment.
Since: 0.1
Notes
Notification type.
Since: 0.1
Instances
| NFData Note Source # | |||||
Defined in Effectful.Notify.Internal.Data.Note | |||||
| Generic Note Source # | |||||
Defined in Effectful.Notify.Internal.Data.Note Associated Types
| |||||
| Show Note Source # | |||||
| Eq Note Source # | |||||
| Ord Note Source # | |||||
| HasField "summary" Note Text Source # | Since: 0.1 | ||||
Defined in Effectful.Notify.Internal.Data.Note | |||||
| (k ~ A_Lens, a ~ Maybe Text, b ~ Maybe Text) => LabelOptic "body" k Note Note a b Source # | Since: 0.1 | ||||
Defined in Effectful.Notify.Internal.Data.Note | |||||
| (k ~ A_Lens, a ~ Text, b ~ Text) => LabelOptic "summary" k Note Note a b Source # | Since: 0.1 | ||||
Defined in Effectful.Notify.Internal.Data.Note | |||||
| (k ~ A_Lens, a ~ Maybe NotifyTimeout, b ~ Maybe NotifyTimeout) => LabelOptic "timeout" k Note Note a b Source # | Since: 0.1 | ||||
Defined in Effectful.Notify.Internal.Data.Note | |||||
| (k ~ A_Lens, a ~ Maybe Text, b ~ Maybe Text) => LabelOptic "title" k Note Note a b Source # | Since: 0.1 | ||||
Defined in Effectful.Notify.Internal.Data.Note | |||||
| (k ~ A_Lens, a ~ Maybe NotifyUrgency, b ~ Maybe NotifyUrgency) => LabelOptic "urgency" k Note Note a b Source # | Since: 0.1 | ||||
Defined in Effectful.Notify.Internal.Data.Note | |||||
| HasField "body" Note (Maybe Text) Source # | Since: 0.1 | ||||
| HasField "timeout" Note (Maybe NotifyTimeout) Source # | Since: 0.1 | ||||
Defined in Effectful.Notify.Internal.Data.Note Methods getField :: Note -> Maybe NotifyTimeout # | |||||
| HasField "title" Note (Maybe Text) Source # | Since: 0.1 | ||||
| HasField "urgency" Note (Maybe NotifyUrgency) Source # | Since: 0.1 | ||||
Defined in Effectful.Notify.Internal.Data.Note Methods getField :: Note -> Maybe NotifyUrgency # | |||||
| type Rep Note Source # | |||||
Defined in Effectful.Notify.Internal.Data.Note type Rep Note = D1 ('MetaData "Note" "Effectful.Notify.Internal.Data.Note" "notify-effectful-0.1-inplace" 'False) (C1 ('MetaCons "MkNoteInternal" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Text)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe NotifyTimeout)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Text)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe NotifyUrgency)))))) | |||||
getSummary :: Note -> Text Source #
Since: 0.1
setTimeout :: Maybe NotifyTimeout -> Note -> Note Source #
Since: 0.1
getTimeout :: Note -> Maybe NotifyTimeout Source #
Since: 0.1
setUrgency :: Maybe NotifyUrgency -> Note -> Note Source #
Since: 0.1
getUrgency :: Note -> Maybe NotifyUrgency Source #
Since: 0.1
Timeout
data NotifyTimeout Source #
Notification timeout, in milliseconds.
Since: 0.1
Constructors
| NotifyTimeoutNever | |
| NotifyTimeoutMillis Int |
Instances
| NFData NotifyTimeout Source # | |||||
Defined in Effectful.Notify.Internal.Data.NotifyTimeout Methods rnf :: NotifyTimeout -> () # | |||||
| Generic NotifyTimeout Source # | |||||
Defined in Effectful.Notify.Internal.Data.NotifyTimeout Associated Types
| |||||
| Show NotifyTimeout Source # | |||||
Defined in Effectful.Notify.Internal.Data.NotifyTimeout Methods showsPrec :: Int -> NotifyTimeout -> ShowS # show :: NotifyTimeout -> String # showList :: [NotifyTimeout] -> ShowS # | |||||
| Eq NotifyTimeout Source # | |||||
Defined in Effectful.Notify.Internal.Data.NotifyTimeout Methods (==) :: NotifyTimeout -> NotifyTimeout -> Bool # (/=) :: NotifyTimeout -> NotifyTimeout -> Bool # | |||||
| Ord NotifyTimeout Source # | |||||
Defined in Effectful.Notify.Internal.Data.NotifyTimeout Methods compare :: NotifyTimeout -> NotifyTimeout -> Ordering # (<) :: NotifyTimeout -> NotifyTimeout -> Bool # (<=) :: NotifyTimeout -> NotifyTimeout -> Bool # (>) :: NotifyTimeout -> NotifyTimeout -> Bool # (>=) :: NotifyTimeout -> NotifyTimeout -> Bool # max :: NotifyTimeout -> NotifyTimeout -> NotifyTimeout # min :: NotifyTimeout -> NotifyTimeout -> NotifyTimeout # | |||||
| Display NotifyTimeout Source # | Since: 0.1 | ||||
Defined in Effectful.Notify.Internal.Data.NotifyTimeout Methods displayBuilder :: NotifyTimeout -> Builder Source # displayList :: [NotifyTimeout] -> Builder Source # displayPrec :: Int -> NotifyTimeout -> Builder Source # | |||||
| HasField "timeout" Note (Maybe NotifyTimeout) Source # | Since: 0.1 | ||||
Defined in Effectful.Notify.Internal.Data.Note Methods getField :: Note -> Maybe NotifyTimeout # | |||||
| type Rep NotifyTimeout Source # | |||||
Defined in Effectful.Notify.Internal.Data.NotifyTimeout type Rep NotifyTimeout = D1 ('MetaData "NotifyTimeout" "Effectful.Notify.Internal.Data.NotifyTimeout" "notify-effectful-0.1-inplace" 'False) (C1 ('MetaCons "NotifyTimeoutNever" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NotifyTimeoutMillis" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int))) | |||||
_NotifyTimeoutMillis :: Prism' NotifyTimeout Int Source #
Since: 0.1
_NotifyTimeoutNever :: Prism' NotifyTimeout () Source #
Since: 0.1
NotifyUrgency
data NotifyUrgency Source #
Notification urgency. Not supported by all notification systems.
Constructors
| NotifyUrgencyLow | Low. |
| NotifyUrgencyNormal | Normal. |
| NotifyUrgencyCritical | Critical. |
Instances
| NFData NotifyUrgency Source # | |||||
Defined in Effectful.Notify.Internal.Data.NotifyUrgency Methods rnf :: NotifyUrgency -> () # | |||||
| Bounded NotifyUrgency Source # | |||||
Defined in Effectful.Notify.Internal.Data.NotifyUrgency | |||||
| Enum NotifyUrgency Source # | |||||
Defined in Effectful.Notify.Internal.Data.NotifyUrgency Methods succ :: NotifyUrgency -> NotifyUrgency # pred :: NotifyUrgency -> NotifyUrgency # toEnum :: Int -> NotifyUrgency # fromEnum :: NotifyUrgency -> Int # enumFrom :: NotifyUrgency -> [NotifyUrgency] # enumFromThen :: NotifyUrgency -> NotifyUrgency -> [NotifyUrgency] # enumFromTo :: NotifyUrgency -> NotifyUrgency -> [NotifyUrgency] # enumFromThenTo :: NotifyUrgency -> NotifyUrgency -> NotifyUrgency -> [NotifyUrgency] # | |||||
| Generic NotifyUrgency Source # | |||||
Defined in Effectful.Notify.Internal.Data.NotifyUrgency Associated Types
| |||||
| Show NotifyUrgency Source # | |||||
Defined in Effectful.Notify.Internal.Data.NotifyUrgency Methods showsPrec :: Int -> NotifyUrgency -> ShowS # show :: NotifyUrgency -> String # showList :: [NotifyUrgency] -> ShowS # | |||||
| Eq NotifyUrgency Source # | |||||
Defined in Effectful.Notify.Internal.Data.NotifyUrgency Methods (==) :: NotifyUrgency -> NotifyUrgency -> Bool # (/=) :: NotifyUrgency -> NotifyUrgency -> Bool # | |||||
| Ord NotifyUrgency Source # | |||||
Defined in Effectful.Notify.Internal.Data.NotifyUrgency Methods compare :: NotifyUrgency -> NotifyUrgency -> Ordering # (<) :: NotifyUrgency -> NotifyUrgency -> Bool # (<=) :: NotifyUrgency -> NotifyUrgency -> Bool # (>) :: NotifyUrgency -> NotifyUrgency -> Bool # (>=) :: NotifyUrgency -> NotifyUrgency -> Bool # max :: NotifyUrgency -> NotifyUrgency -> NotifyUrgency # min :: NotifyUrgency -> NotifyUrgency -> NotifyUrgency # | |||||
| Display NotifyUrgency Source # | Since: 0.1 | ||||
Defined in Effectful.Notify.Internal.Data.NotifyUrgency Methods displayBuilder :: NotifyUrgency -> Builder Source # displayList :: [NotifyUrgency] -> Builder Source # displayPrec :: Int -> NotifyUrgency -> Builder Source # | |||||
| HasField "urgency" Note (Maybe NotifyUrgency) Source # | Since: 0.1 | ||||
Defined in Effectful.Notify.Internal.Data.Note Methods getField :: Note -> Maybe NotifyUrgency # | |||||
| type Rep NotifyUrgency Source # | |||||
Defined in Effectful.Notify.Internal.Data.NotifyUrgency type Rep NotifyUrgency = D1 ('MetaData "NotifyUrgency" "Effectful.Notify.Internal.Data.NotifyUrgency" "notify-effectful-0.1-inplace" 'False) (C1 ('MetaCons "NotifyUrgencyLow" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "NotifyUrgencyNormal" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NotifyUrgencyCritical" 'PrefixI 'False) (U1 :: Type -> Type))) | |||||
_NotifyUrgencyLow :: Prism' NotifyUrgency () Source #
Since: 0.1
_NotifyUrgencyNormal :: Prism' NotifyUrgency () Source #
Since: 0.1
_NotifyUrgencyCritical :: Prism' NotifyUrgency () Source #
Since: 0.1