Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
InvisiXML
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
Model registry
Operate
Environments
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
InvisiXML
Commits
d40e4994
Commit
d40e4994
authored
4 years ago
by
Alice Brenon
Browse files
Options
Downloads
Patches
Plain Diff
Clean commented-out code, expose functions to handle errors and prepare FromXML implementation
parent
5c93d48d
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
lib/Text/InvisiXML/Namespace.hs
+5
-11
5 additions, 11 deletions
lib/Text/InvisiXML/Namespace.hs
lib/Text/XML/Light/Serializer.hs
+11
-4
11 additions, 4 deletions
lib/Text/XML/Light/Serializer.hs
with
16 additions
and
15 deletions
lib/Text/InvisiXML/Namespace.hs
+
5
−
11
View file @
d40e4994
...
...
@@ -3,13 +3,12 @@ module Text.InvisiXML.Namespace (
uRI
,
prefix
,
ixml
--, at
--, to
,
addAttr
,
getAttr
,
setChildren
)
where
--
import Data.
PositionTree (Position(..)
)
import
Data.
List
(
find
)
import
Text.XML.Light
(
Attr
(
..
),
Content
(
..
),
Element
(
..
),
QName
(
..
),
add_attr
)
uRI
::
String
...
...
@@ -21,14 +20,6 @@ prefix = "ixml"
ixml
::
String
->
QName
ixml
qName
=
QName
{
qName
,
qURI
=
Just
uRI
,
qPrefix
=
Just
prefix
}
{-
at :: Position -> Attr
at (Position p) = Attr (ixml "at") (show p)
to :: Position -> Attr
to (Position p) = Attr (ixml "to") (show p)
-}
onContent
::
(
Element
->
Element
)
->
Content
->
Content
onContent
f
(
Elem
e
)
=
Elem
(
f
e
)
onContent
_
x
=
x
...
...
@@ -36,5 +27,8 @@ onContent _ x = x
addAttr
::
Attr
->
Content
->
Content
addAttr
=
onContent
.
add_attr
getAttr
::
QName
->
Element
->
Maybe
String
getAttr
key
=
fmap
attrVal
.
find
((
==
)
key
.
attrKey
)
.
elAttribs
setChildren
::
[
Content
]
->
Content
->
Content
setChildren
elContent
=
onContent
$
\
e
->
e
{
elContent
}
This diff is collapsed.
Click to expand it.
lib/Text/XML/Light/Serializer.hs
+
11
−
4
View file @
d40e4994
module
Text.XML.Light.Serializer
(
FromXML
(
..
)
,
ToXML
(
..
)
,
(
.=
)
,
decode
,
eitherDecode
,
encode
,
(
.=
)
,
expected
)
where
import
Data.List
(
intercalate
)
import
Text.Printf
(
printf
)
import
Text.XML.Light
(
Attr
(
..
),
Content
,
QName
,
parseXML
,
ppContent
)
import
Text.XML.Light.Lexer
(
XmlSource
)
...
...
@@ -16,14 +19,18 @@ class FromXML a where
class
ToXML
a
where
toXML
::
a
->
[
Content
]
encode
::
ToXML
a
=>
a
->
String
encode
=
intercalate
"
\n
"
.
fmap
ppContent
.
toXML
decode
::
(
XmlSource
s
,
FromXML
a
)
=>
s
->
Maybe
a
decode
=
either
(
\
_
->
Nothing
)
Just
.
eitherDecode
eitherDecode
::
(
XmlSource
s
,
FromXML
a
)
=>
s
->
Either
String
a
eitherDecode
=
fromXML
.
parseXML
encode
::
ToXML
a
=>
a
->
String
encode
=
intercalate
"
\n
"
.
fmap
ppContent
.
toXML
(
.=
)
::
Show
v
=>
QName
->
v
->
Attr
k
.=
v
=
Attr
k
$
show
v
expected
::
String
->
[
Content
]
->
Either
String
a
expected
elemType
=
Left
.
printf
"Expected %s but got %s"
elemType
.
concat
.
fmap
ppContent
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