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
eb8574b2
Commit
eb8574b2
authored
Jun 13, 2007
by
nominolo@gmail.com
Browse files
added docs
parent
f511425b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Distribution/ParseUtils.hs
View file @
eb8574b2
...
...
@@ -116,17 +116,24 @@ syntaxError n s = ParseFailed $ FromString s (Just n)
warning
::
String
->
ParseResult
()
warning
s
=
ParseOk
[
s
]
()
-- | Field descriptor. The parameter @a@ parameterizes over where the field's
-- value is stored in.
data
FieldDescr
a
=
FieldDescr
{
fieldName
::
String
,
fieldGet
::
a
->
Doc
,
fieldSet
::
LineNo
->
String
->
a
->
ParseResult
a
-- ^ @fieldSet n str x@ Parses the field value from the given input
-- string @str@ and stores the result in @x@ if the parse was
-- successful. Otherwise, reports an error on line number @n@.
}
field
::
String
->
(
a
->
Doc
)
->
(
ReadP
a
a
)
->
FieldDescr
a
field
name
showF
readF
=
FieldDescr
name
showF
(
\
lineNo
val
_st
->
runP
lineNo
name
readF
val
)
-- Lift a field descriptor storing into an 'a' to a field descriptor storing
-- into a 'b'.
liftField
::
(
b
->
a
)
->
(
a
->
b
->
b
)
->
FieldDescr
a
->
FieldDescr
b
liftField
get
set
(
FieldDescr
name
showF
parseF
)
=
FieldDescr
name
(
\
b
->
showF
(
get
b
))
...
...
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