Tracing
This commit is contained in:
+15
-7
@@ -8,9 +8,9 @@ module AFRP
|
||||
, events
|
||||
, switch
|
||||
, preMapAccum
|
||||
, preMapAccumUTCTime
|
||||
, preMapAccumRequest
|
||||
, mapAccum
|
||||
, mapAccumUTCTime
|
||||
, mapAccumRequest
|
||||
, changes
|
||||
, whenA
|
||||
, filterA
|
||||
@@ -18,6 +18,7 @@ module AFRP
|
||||
, (>>|)
|
||||
, toEvent
|
||||
, lMerge
|
||||
, Request(..)
|
||||
) where
|
||||
|
||||
import Control.Category (Category(..), (>>>))
|
||||
@@ -27,9 +28,16 @@ import Data.Time (UTCTime)
|
||||
import Control.Monad.Fix (MonadFix (mfix))
|
||||
import Data.Either (fromLeft)
|
||||
import Data.Bool (bool)
|
||||
import Data.UUID (UUID)
|
||||
|
||||
data Request = Request
|
||||
{ requestTime :: !UTCTime
|
||||
, requestTraceId :: !UUID
|
||||
}
|
||||
deriving Show
|
||||
|
||||
newtype Mealy eff a b = Mealy
|
||||
{ runMealy :: forall m. MonadFix m => (forall x. eff x -> m x) -> UTCTime -> a -> m (b, Mealy eff a b) }
|
||||
{ runMealy :: forall m. MonadFix m => (forall x. eff x -> m x) -> Request -> a -> m (b, Mealy eff a b) }
|
||||
|
||||
eff :: (a -> eff b) -> Mealy eff a b
|
||||
eff f = Mealy $ \nt _ x ->
|
||||
@@ -101,8 +109,8 @@ preMapAccum f x extract = go x
|
||||
let next = f b a
|
||||
in pure (extract b, go next)
|
||||
|
||||
preMapAccumUTCTime :: (UTCTime -> x -> a -> x) -> x -> (x -> b) -> Mealy eff a b
|
||||
preMapAccumUTCTime f x extract = go x
|
||||
preMapAccumRequest :: (Request -> x -> a -> x) -> x -> (x -> b) -> Mealy eff a b
|
||||
preMapAccumRequest f x extract = go x
|
||||
where
|
||||
go b = Mealy $ \_ t a ->
|
||||
let next = f t b a
|
||||
@@ -115,8 +123,8 @@ mapAccum f x extract = go x
|
||||
let next = f b a
|
||||
in pure (extract next, go next)
|
||||
|
||||
mapAccumUTCTime :: (UTCTime -> x -> a -> x) -> x -> (x -> b) -> Mealy eff a b
|
||||
mapAccumUTCTime f x extract = go x
|
||||
mapAccumRequest :: (Request -> x -> a -> x) -> x -> (x -> b) -> Mealy eff a b
|
||||
mapAccumRequest f x extract = go x
|
||||
where
|
||||
go b = Mealy $ \_ t a ->
|
||||
let next = f t b a
|
||||
|
||||
Reference in New Issue
Block a user