Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
Packages
Cabal
Commits
ff83884b
Commit
ff83884b
authored
May 04, 2016
by
Edsko de Vries
Browse files
Make `Validate` a proper monad
This makes it a bit easier to modify it (for example, during debugging).
parent
58aea459
Changes
1
Hide whitespace changes
Inline
Side-by-side
cabal-install/Distribution/Solver/Modular/Validate.hs
View file @
ff83884b
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module
Distribution.Solver.Modular.Validate
(
validateTree
)
where
-- Validation of the tree.
...
...
@@ -92,7 +94,11 @@ data ValidateState = VS {
qualifyOptions
::
QualifyOptions
}
type
Validate
=
Reader
ValidateState
newtype
Validate
a
=
Validate
(
Reader
ValidateState
a
)
deriving
(
Functor
,
Applicative
,
Monad
,
MonadReader
ValidateState
)
runValidate
::
Validate
a
->
ValidateState
->
a
runValidate
(
Validate
r
)
=
runReader
r
validate
::
Tree
QGoalReason
->
Validate
(
Tree
QGoalReason
)
validate
=
cata
go
...
...
@@ -255,7 +261,7 @@ extractNewDeps v b fa sa = go
-- | Interface.
validateTree
::
CompilerInfo
->
Index
->
PkgConfigDb
->
Tree
QGoalReason
->
Tree
QGoalReason
validateTree
cinfo
idx
pkgConfigDb
t
=
run
Reader
(
validate
t
)
VS
{
validateTree
cinfo
idx
pkgConfigDb
t
=
run
Validate
(
validate
t
)
VS
{
supportedExt
=
maybe
(
const
True
)
-- if compiler has no list of extensions, we assume everything is supported
(
\
es
->
let
s
=
S
.
fromList
es
in
\
x
->
S
.
member
x
s
)
(
compilerInfoExtensions
cinfo
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment