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
3bcf720a
Commit
3bcf720a
authored
2 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Remove redundant constraints
parent
36dc2211
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
quasar/src/Quasar/PreludeExtras.hs
+4
-4
4 additions, 4 deletions
quasar/src/Quasar/PreludeExtras.hs
with
4 additions
and
4 deletions
quasar/src/Quasar/PreludeExtras.hs
+
4
−
4
View file @
3bcf720a
...
...
@@ -65,7 +65,7 @@ leftToMaybe (Left x) = Just x
leftToMaybe
(
Right
_
)
=
Nothing
-- | Returns all duplicate elements in a list. The order of the produced list is unspecified.
duplicates
::
forall
a
.
(
Eq
a
,
Hashable
.
Hashable
a
)
=>
[
a
]
->
[
a
]
duplicates
::
forall
a
.
Hashable
.
Hashable
a
=>
[
a
]
->
[
a
]
duplicates
=
HS
.
toList
.
duplicates'
HS
.
empty
where
duplicates'
::
HS
.
HashSet
a
->
[
a
]
->
HS
.
HashSet
a
...
...
@@ -77,14 +77,14 @@ duplicates = HS.toList . duplicates' HS.empty
otherDuplicates
=
duplicates'
(
HS
.
insert
x
set
)
xs
-- | Lookup and delete a value from a HashMap in one operation
lookupDelete
::
forall
k
v
.
(
Eq
k
,
Hashable
.
Hashable
k
)
=>
k
->
HM
.
HashMap
k
v
->
(
Maybe
v
,
HM
.
HashMap
k
v
)
lookupDelete
::
forall
k
v
.
Hashable
.
Hashable
k
=>
k
->
HM
.
HashMap
k
v
->
(
Maybe
v
,
HM
.
HashMap
k
v
)
lookupDelete
key
m
=
swap
$
State
.
runState
fn
Nothing
where
fn
::
State
.
State
(
Maybe
v
)
(
HM
.
HashMap
k
v
)
fn
=
HM
.
alterF
(
\
c
->
State
.
put
c
>>
return
Nothing
)
key
m
-- | Lookup a value and insert the given value if it is not already a member of the HashMap.
lookupInsert
::
forall
k
v
.
(
Eq
k
,
Hashable
.
Hashable
k
)
=>
k
->
v
->
HM
.
HashMap
k
v
->
(
v
,
HM
.
HashMap
k
v
)
lookupInsert
::
forall
k
v
.
Hashable
.
Hashable
k
=>
k
->
v
->
HM
.
HashMap
k
v
->
(
v
,
HM
.
HashMap
k
v
)
lookupInsert
key
value
hm
=
runExtra
$
HM
.
alterF
fn
key
hm
where
fn
::
Maybe
v
->
Extra
v
(
Maybe
v
)
...
...
@@ -92,7 +92,7 @@ lookupInsert key value hm = runExtra $ HM.alterF fn key hm
fn
(
Just
oldValue
)
=
Extra
(
oldValue
,
Just
oldValue
)
-- | Insert the given value if it is not already a member of the HashMap. Returns `True` if the element was inserted.
checkInsert
::
forall
k
v
.
(
Eq
k
,
Hashable
.
Hashable
k
)
=>
k
->
v
->
HM
.
HashMap
k
v
->
(
Bool
,
HM
.
HashMap
k
v
)
checkInsert
::
forall
k
v
.
Hashable
.
Hashable
k
=>
k
->
v
->
HM
.
HashMap
k
v
->
(
Bool
,
HM
.
HashMap
k
v
)
checkInsert
key
value
hm
=
runExtra
$
HM
.
alterF
fn
key
hm
where
fn
::
Maybe
v
->
Extra
Bool
(
Maybe
v
)
...
...
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