Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
quasar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jens Nolte
quasar
Commits
28d861e2
Commit
28d861e2
authored
4 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Replace Updateable with Settable class
parent
d34bd2d7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lib/Qd/Observable.hs
+9
-0
9 additions, 0 deletions
src/lib/Qd/Observable.hs
with
9 additions
and
0 deletions
src/lib/Qd/Observable.hs
+
9
−
0
View file @
28d861e2
...
...
@@ -6,6 +6,7 @@ module Qd.Observable (
subscribe'
,
SubscriptionHandle
(
..
),
RegistrationHandle
(
..
),
Settable
(
..
),
Disposable
(
..
),
ObservableCallback
,
ObservableState
,
...
...
@@ -72,6 +73,10 @@ instance Observable v o => Observable v (IO o) where
subscribe
observable
callback
class
Settable
v
a
where
setValue
::
a
->
v
->
IO
()
-- | Existential quantification wrapper for the Observable type class.
data
SomeObservable
v
=
forall
o
.
Observable
v
o
=>
SomeObservable
o
instance
Observable
v
(
SomeObservable
v
)
where
...
...
@@ -105,6 +110,10 @@ instance Observable v (BasicObservable v) where
unsubscribe'
::
Unique
->
IO
()
unsubscribe'
key
=
modifyMVar_
mvar
$
\
(
state
,
subscribers
)
->
return
(
state
,
HM
.
delete
key
subscribers
)
instance
Settable
v
(
BasicObservable
v
)
where
setValue
basicObservable
=
setBasicObservable
basicObservable
.
Just
createBasicObservable
::
Maybe
v
->
IO
(
BasicObservable
v
)
createBasicObservable
defaultValue
=
do
BasicObservable
<$>
newMVar
(
defaultValue
,
HM
.
empty
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment