Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TrevouxGrammar
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
Alice Brenon
TrevouxGrammar
Commits
a85b8e16
Commit
a85b8e16
authored
3 years ago
by
Alice Brenon
Browse files
Options
Downloads
Patches
Plain Diff
More readable error messages with operator <!> showing an excerpt of what has been actually read
parent
aa302481
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/Text/Encyclopedia/Article.hs
+13
-7
13 additions, 7 deletions
lib/Text/Encyclopedia/Article.hs
with
13 additions
and
7 deletions
lib/Text/Encyclopedia/Article.hs
+
13
−
7
View file @
a85b8e16
...
@@ -34,6 +34,15 @@ data Article = Article {
...
@@ -34,6 +34,15 @@ data Article = Article {
,
body
::
Text
,
body
::
Text
}
deriving
(
Eq
,
Show
)
}
deriving
(
Eq
,
Show
)
(
<!>
)
::
Parser
a
->
String
->
Parser
a
(
<!>
)
p
expected
=
p
<|>
(
takeText
>>=
fail
.
formatMessage
)
where
ellipsis
s
|
Prelude
.
length
s
<
21
=
s
|
otherwise
=
take
20
s
++
"…"
formatMessage
=
printf
"%s (got «%s»)"
expected
.
ellipsis
.
Text
.
unpack
infix
0
<!>
article
::
Parser
Article
article
::
Parser
Article
article
=
Article
<$>
headwords_
<*>
optional
inflectedPOS_
<*>
body_
article
=
Article
<$>
headwords_
<*>
optional
inflectedPOS_
<*>
body_
...
@@ -58,7 +67,8 @@ many1Till :: Parser a -> Parser b -> Parser [a]
...
@@ -58,7 +67,8 @@ many1Till :: Parser a -> Parser b -> Parser [a]
many1Till
p
after
=
(
:
)
<$>
p
<*>
manyTill
p
after
many1Till
p
after
=
(
:
)
<$>
p
<*>
manyTill
p
after
headwords_
::
Parser
[
String
]
headwords_
::
Parser
[
String
]
headwords_
=
headword
`
sepBy1
`
headwordSeparator
<*
blank
headwords_
=
(
headword
`
sepBy1
`
headwordSeparator
<!>
"at least one headword"
)
<*
blank
where
where
headword
=
headword
=
satisfy
isUpper
`
many1Till
`
lookAhead
(
sentenceBegining
<|>
punctOrSpace
)
satisfy
isUpper
`
many1Till
`
lookAhead
(
sentenceBegining
<|>
punctOrSpace
)
...
@@ -75,11 +85,7 @@ inflectedPOS_ :: Parser InflectedPOS
...
@@ -75,11 +85,7 @@ inflectedPOS_ :: Parser InflectedPOS
inflectedPOS_
=
InflectedPOS
inflectedPOS_
=
InflectedPOS
<$>
(
punctOrSpace
*>
abbreviation
<*
blank
)
<$>
(
punctOrSpace
*>
abbreviation
<*
blank
)
<*>
(
optional
abbreviation
<*
blank
)
<*>
(
optional
abbreviation
<*
blank
)
<!>
"inflectedPOS"
body_
::
Parser
Text
body_
::
Parser
Text
body_
=
Text
.
append
<$>
sentenceBegining
<*>
takeText
<|>
debug
body_
=
Text
.
append
<$>
sentenceBegining
<*>
takeText
<!>
"body"
where
debug
=
takeText
>>=
fail
.
printf
"body (got «%s»)"
.
ellipsis
.
Text
.
unpack
ellipsis
s
|
Prelude
.
length
s
<
21
=
s
|
otherwise
=
take
20
s
++
"…"
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