-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Lifting instances for Reflex.Profiled
#398
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ import Control.Monad.Primitive | |
import Control.Monad.Reader | ||
import Control.Monad.Ref | ||
import Control.Monad.State.Strict (StateT, execStateT, modify) | ||
import Data.Bifunctor | ||
import Data.Coerce | ||
import Data.Dependent.Map (DMap, GCompare) | ||
import Data.FastMutableIntMap | ||
|
@@ -42,12 +43,20 @@ import Foreign.Ptr | |
import GHC.Foreign | ||
import GHC.IO.Encoding | ||
import GHC.Stack | ||
import Reflex.Adjustable.Class | ||
import Reflex.BehaviorWriter.Class | ||
import Reflex.Class | ||
import Reflex.DynamicWriter.Class | ||
import Reflex.EventWriter.Class | ||
import Reflex.Host.Class | ||
import Reflex.NotReady.Class | ||
import Reflex.PerformEvent.Class | ||
import Reflex.PostBuild.Class | ||
import Reflex.Query.Class | ||
import Reflex.Requester.Class | ||
import Reflex.TriggerEvent.Class | ||
|
||
import System.IO.Unsafe | ||
import Unsafe.Coerce | ||
|
||
data ProfiledTimeline t | ||
|
||
|
@@ -178,6 +187,16 @@ instance MonadHold t m => MonadHold (ProfiledTimeline t) (ProfiledM m) where | |
instance MonadSample t m => MonadSample (ProfiledTimeline t) (ProfiledM m) where | ||
sample (Behavior_Profiled b) = ProfiledM $ sample b | ||
|
||
instance Adjustable t m => Adjustable (ProfiledTimeline t) (ProfiledM m) where | ||
runWithReplace a0 a' = (fmap . fmap) coerce . lift $ | ||
runWithReplace (coerce a0) (coerce $ coerce <$> a') | ||
traverseIntMapWithKeyWithAdjust f dm0 dm' = (fmap . fmap) coerce . lift $ | ||
traverseIntMapWithKeyWithAdjust (\k v -> coerce $ f k v) dm0 (coerce dm') | ||
traverseDMapWithKeyWithAdjust f dm0 dm' = (fmap . fmap) coerce . lift $ | ||
traverseDMapWithKeyWithAdjust (\k v -> coerce $ f k v) dm0 (coerce dm') | ||
traverseDMapWithKeyWithAdjustWithMove f dm0 dm' = (fmap . fmap) coerce . lift $ | ||
traverseDMapWithKeyWithAdjustWithMove (\k v -> coerce $ f k v) dm0 (coerce dm') | ||
|
||
instance MonadTrans ProfiledM where | ||
lift = ProfiledM | ||
|
||
|
@@ -189,6 +208,39 @@ instance PerformEvent t m => PerformEvent (ProfiledTimeline t) (ProfiledM m) whe | |
performEvent_ = lift . performEvent_ . coerce | ||
performEvent = lift . fmap coerce . performEvent . coerce | ||
|
||
instance TriggerEvent t m => TriggerEvent (ProfiledTimeline t) (ProfiledM m) where | ||
newTriggerEvent = first coerce <$> lift newTriggerEvent | ||
newTriggerEventWithOnComplete = first coerce <$> lift newTriggerEventWithOnComplete | ||
newEventWithLazyTriggerWithOnComplete f = coerce <$> lift (newEventWithLazyTriggerWithOnComplete f) | ||
|
||
instance PostBuild t m => PostBuild (ProfiledTimeline t) (ProfiledM m) where | ||
getPostBuild = coerce <$> lift getPostBuild | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one might be too There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly: getPostBuild :: m (Event t ())
-- vs.
getPostBuild :: ProfiledM m (Event (ProfiledTimeline t) ()) |
||
|
||
instance NotReady t m => NotReady (ProfiledTimeline t) (ProfiledM m) where | ||
notReady = lift notReady | ||
notReadyUntil = lift . notReadyUntil . coerce | ||
|
||
instance BehaviorWriter t w m => BehaviorWriter (ProfiledTimeline t) w (ProfiledM m) where | ||
tellBehavior = lift . tellBehavior . coerce | ||
|
||
instance DynamicWriter t w m => DynamicWriter (ProfiledTimeline t) w (ProfiledM m) where | ||
tellDyn = lift . tellDyn . coerce | ||
|
||
instance EventWriter t w m => EventWriter (ProfiledTimeline t) w (ProfiledM m) where | ||
tellEvent = lift . tellEvent . coerce | ||
|
||
instance MonadQuery t q m => MonadQuery (ProfiledTimeline t) q (ProfiledM m) where | ||
tellQueryIncremental = lift . tellQueryIncremental . coerce | ||
askQueryResult = coerce <$> lift askQueryResult | ||
queryIncremental = fmap coerce . lift . queryIncremental . coerce | ||
|
||
instance Requester t m => Requester (ProfiledTimeline t) (ProfiledM m) where | ||
type Request (ProfiledM m) = Request m | ||
type Response (ProfiledM m) = Response m | ||
|
||
requesting = fmap coerce . lift . requesting . coerce | ||
requesting_ = lift . requesting_ . coerce | ||
|
||
instance MonadRef m => MonadRef (ProfiledM m) where | ||
type Ref (ProfiledM m) = Ref m | ||
newRef = lift . newRef | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one looks wrong. Could you add a signature to ensure it's correct with:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(wrong because you should have to coerce f in some way)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand your concern for other instances, but I don't see how it applies here. Why should
f
be coerced?I don't see how
f
changes.