Skip to content
GitLab
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
a7cc266a
Commit
a7cc266a
authored
Oct 08, 2016
by
Oleg Grenrus
Browse files
Add ModuleName.fromComponents
parent
6dea5762
Changes
1
Hide whitespace changes
Inline
Side-by-side
Cabal/Distribution/ModuleName.hs
View file @
a7cc266a
...
...
@@ -15,6 +15,7 @@
module
Distribution.ModuleName
(
ModuleName
,
fromString
,
fromComponents
,
components
,
toFilePath
,
main
,
...
...
@@ -74,18 +75,21 @@ simple str = ModuleName (stlFromStrings [str])
-- are parsing user input then use 'Distribution.Text.simpleParse' instead.
--
fromString
::
String
->
ModuleName
fromString
string
|
all
validModuleComponent
components'
=
ModuleName
(
stlFromStrings
components'
)
|
otherwise
=
error
badName
fromString
string
=
fromComponents
(
split
string
)
where
components'
=
split
string
badName
=
"ModuleName.fromString: invalid module name "
++
show
string
split
cs
=
case
break
(
==
'.'
)
cs
of
(
chunk
,
[]
)
->
chunk
:
[]
(
chunk
,
_
:
rest
)
->
chunk
:
split
rest
-- | Construct a 'ModuleName' from valid module components, i.e. parts
-- separated by dots.
fromComponents
::
[
String
]
->
ModuleName
fromComponents
components'
|
all
validModuleComponent
components'
=
ModuleName
(
stlFromStrings
components'
)
|
otherwise
=
error
badName
where
badName
=
"ModuleName.fromComponents: invalid components "
++
show
components'
-- | The module name @Main@.
--
main
::
ModuleName
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment