Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
obsidiansystems
GHC
Commits
e07185ed
Commit
e07185ed
authored
16 years ago
by
batterseapower
Browse files
Options
Downloads
Patches
Plain Diff
Move allM to MonadUtils
parent
393f2662
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
compiler/utils/Digraph.lhs
+1
-4
1 addition, 4 deletions
compiler/utils/Digraph.lhs
compiler/utils/MonadUtils.hs
+7
-2
7 additions, 2 deletions
compiler/utils/MonadUtils.hs
with
8 additions
and
6 deletions
compiler/utils/Digraph.lhs
+
1
−
4
View file @
e07185ed
...
@@ -40,6 +40,7 @@ module Digraph(
...
@@ -40,6 +40,7 @@ module Digraph(
import Util ( sortLe )
import Util ( sortLe )
import Outputable
import Outputable
import Maybes ( expectJust )
import Maybes ( expectJust )
import MonadUtils ( allM )
-- Extensions
-- Extensions
import Control.Monad ( filterM, liftM, liftM2 )
import Control.Monad ( filterM, liftM, liftM2 )
...
@@ -588,8 +589,4 @@ vertexGroupsS provided g to_provide
...
@@ -588,8 +589,4 @@ vertexGroupsS provided g to_provide
vertexReady :: Set s -> IntGraph -> Vertex -> ST s Bool
vertexReady :: Set s -> IntGraph -> Vertex -> ST s Bool
vertexReady provided g v = liftM2 (&&) (liftM not $ provided `contains` v) (allM (provided `contains`) (g!v))
vertexReady provided g v = liftM2 (&&) (liftM not $ provided `contains` v) (allM (provided `contains`) (g!v))
allM :: Monad m => (a -> m Bool) -> [a] -> m Bool
allM _ [] = return True
allM f (b:bs) = (f b) >>= (\bv -> if bv then allM f bs else return False)
\end{code}
\end{code}
This diff is collapsed.
Click to expand it.
compiler/utils/MonadUtils.hs
+
7
−
2
View file @
e07185ed
...
@@ -13,7 +13,7 @@ module MonadUtils
...
@@ -13,7 +13,7 @@ module MonadUtils
,
mapAccumLM
,
mapAccumLM
,
mapSndM
,
mapSndM
,
concatMapM
,
concatMapM
,
anyM
,
anyM
,
allM
,
foldlM
,
foldrM
,
foldlM
,
foldrM
)
where
)
where
...
@@ -116,13 +116,18 @@ mapSndM f ((a,b):xs) = do { c <- f b; rs <- mapSndM f xs; return ((a,c):rs) }
...
@@ -116,13 +116,18 @@ mapSndM f ((a,b):xs) = do { c <- f b; rs <- mapSndM f xs; return ((a,c):rs) }
concatMapM
::
Monad
m
=>
(
a
->
m
[
b
])
->
[
a
]
->
m
[
b
]
concatMapM
::
Monad
m
=>
(
a
->
m
[
b
])
->
[
a
]
->
m
[
b
]
concatMapM
f
xs
=
liftM
concat
(
mapM
f
xs
)
concatMapM
f
xs
=
liftM
concat
(
mapM
f
xs
)
-- | Monadic version of 'any', aborts the computation at the first
False
value
-- | Monadic version of 'any', aborts the computation at the first
@True@
value
anyM
::
Monad
m
=>
(
a
->
m
Bool
)
->
[
a
]
->
m
Bool
anyM
::
Monad
m
=>
(
a
->
m
Bool
)
->
[
a
]
->
m
Bool
anyM
_
[]
=
return
False
anyM
_
[]
=
return
False
anyM
f
(
x
:
xs
)
=
do
b
<-
f
x
anyM
f
(
x
:
xs
)
=
do
b
<-
f
x
if
b
then
return
True
if
b
then
return
True
else
anyM
f
xs
else
anyM
f
xs
-- | Monad version of 'all', aborts the computation at the first @False@ value
allM
::
Monad
m
=>
(
a
->
m
Bool
)
->
[
a
]
->
m
Bool
allM
_
[]
=
return
True
allM
f
(
b
:
bs
)
=
(
f
b
)
>>=
(
\
bv
->
if
bv
then
allM
f
bs
else
return
False
)
-- | Monadic version of foldl
-- | Monadic version of foldl
foldlM
::
(
Monad
m
)
=>
(
a
->
b
->
m
a
)
->
a
->
[
b
]
->
m
a
foldlM
::
(
Monad
m
)
=>
(
a
->
b
->
m
a
)
->
a
->
[
b
]
->
m
a
foldlM
=
foldM
foldlM
=
foldM
...
...
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