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
a064c28e
Commit
a064c28e
authored
Mar 10, 2008
by
Duncan Coutts
Browse files
Import Data.Tree rather than defining it locally
Since we've dropped ghc-6.2 compatibility we can now use Data.Tree directly.
parent
af3fc863
Changes
1
Hide whitespace changes
Inline
Side-by-side
Distribution/ParseUtils.hs
View file @
a064c28e
...
...
@@ -75,6 +75,7 @@ import Language.Haskell.Extension (Extension)
import
Text.PrettyPrint.HughesPJ
hiding
(
braces
)
import
Data.Char
(
isSpace
,
isUpper
,
toLower
,
isAlphaNum
,
isSymbol
,
isDigit
)
import
Data.Maybe
(
fromMaybe
)
import
Data.Tree
as
Tree
(
Tree
(
..
),
flatten
)
#
ifdef
DEBUG
import
Test.HUnit
(
Test
(
..
),
assertBool
,
Assertion
,
runTestTT
,
Counts
,
assertEqual
)
...
...
@@ -444,7 +445,7 @@ mkField d (Node (n,t,_) _) | d >= 1 && t = tabsError n
mkField
d
(
Node
(
n
,
_
,
l
)
ts
)
=
case
span
(
\
c
->
isAlphaNum
c
||
c
==
'-'
)
l
of
(
[]
,
_
)
->
syntaxError
n
$
"unrecognised field or section: "
++
show
l
(
name
,
rest
)
->
case
trimLeading
rest
of
(
':'
:
rest'
)
->
do
let
followingLines
=
concatMap
flatten
ts
(
':'
:
rest'
)
->
do
let
followingLines
=
concatMap
Tree
.
flatten
ts
tabs
=
not
(
null
[
()
|
(
_
,
True
,
_
)
<-
followingLines
])
if
tabs
&&
d
>=
1
then
tabsError
n
...
...
@@ -625,18 +626,6 @@ showDependency (Dependency name ver) = text name <+> text (showVersionRange ver)
showFreeText
::
String
->
Doc
showFreeText
s
=
vcat
[
text
(
if
null
l
then
"."
else
l
)
|
l
<-
lines
s
]
-- --------------------------------------------
-- ** Tree bits
-- Data.Tree was not present in ghc-6.2, and we only need these bits:
data
Tree
a
=
Node
a
(
Forest
a
)
type
Forest
a
=
[
Tree
a
]
flatten
::
Tree
a
->
[
a
]
flatten
t
=
squish
t
[]
where
squish
(
Node
x
ts
)
xs
=
x
:
foldr
squish
xs
ts
------------------------------------------------------------------------------
-- TESTING
...
...
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