packages feed

eventuo11y 0.3.2.0 → 0.4.0.0

raw patch · 6 files changed

+26/−52 lines, 6 filesdep ~aesonPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: aeson

API changes (from Hackage documentation)

- Observe.Event: causedEventBackend :: Monad m => Event m r s f -> EventBackend m r s
- Observe.Event: hoistEvent :: (Functor m, Functor n) => (forall x. m x -> n x) -> Event m r s f -> Event n r s f
- Observe.Event.Backend: hoistEventImpl :: (forall x. m x -> n x) -> EventImpl m r f -> EventImpl n r f
- Observe.Event.Render.JSON: SomeJSONException :: e -> SomeJSONException
+ Observe.Event.Render.JSON: SomeJSONException :: RenderExJSON e -> e -> SomeJSONException
- Observe.Event.Render.JSON: jsonExceptionToException :: (Exception e, ToJSON e) => e -> SomeException
+ Observe.Event.Render.JSON: jsonExceptionToException :: Exception e => RenderExJSON e -> e -> SomeException

Files

CHANGELOG.md view
@@ -1,12 +1,8 @@ # Revision history for eventuo11y -## 0.3.2.0 -- 2022-10-04--Add hoistEvent--## 0.3.1.0 -- 2022-10-04+## 0.4.0.0 -- 2022-10-04 -Add causedEventBackend+Have SomeJSONException take a RenderExJSON directly  ## 0.3.0.0 -- 2022-10-03 
Example.hs view
@@ -15,7 +15,7 @@ import Data.Void import Foreign.C.Error import Foreign.C.Types-import Foreign.ForeignPtr.Safe+import Foreign.ForeignPtr import Foreign.Ptr import GHC.Generics import Observe.Event@@ -99,7 +99,7 @@  -- Our exception is beneath SomeJSONException in the hierarchy instance Exception BadOpen where-  toException = jsonExceptionToException+  toException = jsonExceptionToException toJSON   fromException = jsonExceptionFromException  -- end module File
eventuo11y.cabal view
@@ -1,6 +1,6 @@ cabal-version:      3.0 name:               eventuo11y-version:            0.3.2.0+version:            0.4.0.0 synopsis:           An event-oriented observability library description:   Instrument your Haskell codebase with wide, semantically meaningful events.@@ -26,7 +26,7 @@   See "Observe.Event.Backend" for documentation on writing an   @EventBackend@. -  See [Example.hs](https://github.com/shlevy/eventuo11y/tree/v0.3.2.0/Example.hs) for an example.+  See [Example.hs](https://github.com/shlevy/eventuo11y/tree/v0.4.0.0/Example.hs) for an example.    See [eventuo11y-batteries](https://hackage.haskell.org/package/eventuo11y-batteries) for miscellaneous   framework-specific helpers.@@ -58,7 +58,7 @@     Observe.Event.Render.JSON    build-depends:-    , aeson          ^>=2.0.2.0+    , aeson          ^>=2.0     , base           >=4.14    && <4.17     , bytestring     >=0.10    && <0.12     , exceptions     ^>=0.10
src/Observe/Event.hs view
@@ -40,7 +40,6 @@ --  t'Observe.Event.Render.JSON.RenderFieldJSON' to use JSON rendering 'EventBackend's. module Observe.Event   ( Event,-    hoistEvent,      -- * Event manipulation #eventmanip#     reference,@@ -59,7 +58,6 @@     -- * 'EventBackend's     EventBackend,     subEventBackend,-    causedEventBackend,     unitEventBackend,     pairEventBackend,     hoistEventBackend,@@ -106,15 +104,6 @@     finishFlag :: !(OnceFlag m)   } --- | Hoist an 'Event' along a given natural transformation into a new monad.-hoistEvent :: (Functor m, Functor n) => (forall x. m x -> n x) -> Event m r s f -> Event n r s f-hoistEvent nt Event {..} =-  Event-    { backend = hoistEventBackend nt backend,-      impl = hoistEventImpl nt impl,-      finishFlag = hoistOnceFlag nt finishFlag-    }- -- | Obtain a reference to an 'Event'. -- -- References are used to link 'Event's together, either in@@ -334,12 +323,3 @@   Event m r s f ->   EventBackend m r s subEventBackend Event {..} = modifyEventBackend (setAncestor $ referenceImpl impl) backend---- | An 'EventBackend' where every otherwise causeless event will be marked--- as caused by the given 'Event'.-causedEventBackend ::-  (Monad m) =>-  -- | The parent event.-  Event m r s f ->-  EventBackend m r s-causedEventBackend Event {..} = modifyEventBackend (setInitialCause $ referenceImpl impl) backend
src/Observe/Event/Backend.hs view
@@ -18,7 +18,6 @@     unitEventBackend,     pairEventBackend,     hoistEventBackend,-    hoistEventImpl,     narrowEventBackend,     narrowEventBackend', @@ -155,21 +154,19 @@   EventBackend n r s hoistEventBackend nt backend =   EventBackend-    { newEventImpl = nt . fmap (hoistEventImpl nt) . newEventImpl backend,+    { newEventImpl = nt . fmap hoistEventImpl . newEventImpl backend,       newOnceFlag = hoistOnceFlag nt <$> (nt $ newOnceFlag backend)     }---- | Hoist an 'EventImpl' along a given natural transformation into a new monad.-hoistEventImpl :: (forall x. m x -> n x) -> EventImpl m r f -> EventImpl n r f-hoistEventImpl nt (EventImpl {..}) =-  EventImpl-    { referenceImpl,-      addFieldImpl = nt . addFieldImpl,-      addParentImpl = nt . addParentImpl,-      addProximateImpl = nt . addProximateImpl,-      finalizeImpl = nt finalizeImpl,-      failImpl = nt . failImpl-    }+  where+    hoistEventImpl (EventImpl {..}) =+      EventImpl+        { referenceImpl,+          addFieldImpl = nt . addFieldImpl,+          addParentImpl = nt . addParentImpl,+          addProximateImpl = nt . addProximateImpl,+          finalizeImpl = nt $ finalizeImpl,+          failImpl = nt . failImpl+        }  -- | Narrow an 'EventBackend' to a new selector type via a given injection function. --
src/Observe/Event/Render/JSON.hs view
@@ -64,27 +64,28 @@ -- structured exceptions in a JSON backend, so long as you provide a -- 'RenderExJSON' for your base exception type. renderJSONException :: RenderExJSON SomeJSONException-renderJSONException (SomeJSONException e) = toJSON e+renderJSONException (SomeJSONException render e) = render e  -- | A possible base type for structured exceptions renderable to JSON. -- -- It is __not__ necessary to use 'SomeJSONException' for the base of your -- structured exceptions in a JSON backend, so long as you provide a -- 'RenderExJSON' for your base exception type.-data SomeJSONException = forall e. (Exception e, ToJSON e) => SomeJSONException e+data SomeJSONException+  = forall e. Exception e => SomeJSONException (RenderExJSON e) e  instance Show SomeJSONException where-  show (SomeJSONException e) = show e-  showsPrec i (SomeJSONException e) = showsPrec i e+  show (SomeJSONException _ e) = show e+  showsPrec i (SomeJSONException _ e) = showsPrec i e  instance Exception SomeJSONException  -- | Used to create sub-classes of 'SomeJSONException'.-jsonExceptionToException :: (Exception e, ToJSON e) => e -> SomeException-jsonExceptionToException = toException . SomeJSONException+jsonExceptionToException :: (Exception e) => RenderExJSON e -> e -> SomeException+jsonExceptionToException render = toException . SomeJSONException render  -- | Used to create sub-classes of 'SomeJSONException'. jsonExceptionFromException :: (Exception e) => SomeException -> Maybe e jsonExceptionFromException x = do-  SomeJSONException a <- fromException x+  SomeJSONException _ a <- fromException x   cast a