Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Glasgow Haskell Compiler
Packages
Cabal
Commits
bfc13826
Commit
bfc13826
authored
Jul 24, 2012
by
Brent Yorgey
Committed by
tibbe
Aug 13, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cabal init: add support for default-language field
parent
78bad98a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
1 deletion
+36
-1
cabal-install/Distribution/Client/Init.hs
cabal-install/Distribution/Client/Init.hs
+24
-1
cabal-install/Distribution/Client/Init/Types.hs
cabal-install/Distribution/Client/Init/Types.hs
+4
-0
cabal-install/Distribution/Client/Setup.hs
cabal-install/Distribution/Client/Setup.hs
+8
-0
No files found.
cabal-install/Distribution/Client/Init.hs
View file @
bfc13826
...
...
@@ -63,6 +63,7 @@ import Distribution.ModuleName
import
Distribution.InstalledPackageInfo
(
InstalledPackageInfo
,
sourcePackageId
,
exposed
)
import
qualified
Distribution.Package
as
P
import
Language.Haskell.Extension
(
Language
(
..
)
)
import
Distribution.Client.Init.Types
(
InitFlags
(
..
),
PackageType
(
..
),
Category
(
..
)
)
...
...
@@ -127,6 +128,7 @@ extendFlags pkgIx =
>=>
getSynopsis
>=>
getCategory
>=>
getLibOrExec
>=>
getLanguage
>=>
getGenComments
>=>
getSrcDir
>=>
getModulesBuildToolsAndDeps
pkgIx
...
...
@@ -242,7 +244,24 @@ getLibOrExec flags = do
return
$
flags
{
packageType
=
maybeToFlag
isLib
}
-- | Ask whether to generate explanitory comments.
-- | Ask for the base language of the package.
getLanguage
::
InitFlags
->
IO
InitFlags
getLanguage
flags
=
do
lang
<-
return
(
flagToMaybe
$
language
flags
)
?>>
maybePrompt
flags
(
either
UnknownLanguage
id
`
fmap
`
(
promptList
"What base language is the package written in"
[
Haskell2010
,
Haskell98
]
(
Just
Haskell2010
)
display
True
)
)
?>>
return
(
Just
Haskell2010
)
return
$
flags
{
language
=
maybeToFlag
lang
}
-- | Ask whether to generate explanatory comments.
getGenComments
::
InitFlags
->
IO
InitFlags
getGenComments
flags
=
do
genComments
<-
return
(
not
<$>
(
flagToMaybe
$
noComments
flags
))
...
...
@@ -678,6 +697,10 @@ generateCabalFile fileName c =
,
fieldS
"build-tools"
(
listFieldS
(
buildTools
c'
))
(
Just
"Extra tools (e.g. alex, hsc2hs, ...) needed to build the source."
)
False
,
field
"default-language"
(
language
c'
)
(
Just
"Base language which the package is written in."
)
True
]
listField
::
Text
s
=>
Maybe
[
s
]
->
Flag
String
...
...
cabal-install/Distribution/Client/Init/Types.hs
View file @
bfc13826
...
...
@@ -22,6 +22,7 @@ import Distribution.Verbosity
import
qualified
Distribution.Package
as
P
import
Distribution.License
import
Distribution.ModuleName
import
Language.Haskell.Extension
(
Language
(
..
)
)
import
qualified
Text.PrettyPrint
as
Disp
import
qualified
Distribution.Compat.ReadP
as
Parse
...
...
@@ -53,6 +54,7 @@ data InitFlags =
,
category
::
Flag
(
Either
String
Category
)
,
packageType
::
Flag
PackageType
,
language
::
Flag
Language
,
exposedModules
::
Maybe
[
ModuleName
]
,
otherModules
::
Maybe
[
ModuleName
]
...
...
@@ -90,6 +92,7 @@ instance Monoid InitFlags where
,
synopsis
=
mempty
,
category
=
mempty
,
packageType
=
mempty
,
language
=
mempty
,
exposedModules
=
mempty
,
otherModules
=
mempty
,
dependencies
=
mempty
...
...
@@ -114,6 +117,7 @@ instance Monoid InitFlags where
,
synopsis
=
combine
synopsis
,
category
=
combine
category
,
packageType
=
combine
packageType
,
language
=
combine
language
,
exposedModules
=
combine
exposedModules
,
otherModules
=
combine
otherModules
,
dependencies
=
combine
dependencies
...
...
cabal-install/Distribution/Client/Setup.hs
View file @
bfc13826
...
...
@@ -1052,6 +1052,14 @@ initCommand = CommandUI {
(
\
v
flags
->
flags
{
IT
.
packageType
=
v
})
(
noArg
(
Flag
IT
.
Executable
))
,
option
[]
[
"language"
]
"Specify the default language."
IT
.
language
(
\
v
flags
->
flags
{
IT
.
language
=
v
})
(
reqArg
"LANGUAGE"
(
readP_to_E
(
"Cannot parse language: "
++
)
(
toFlag
`
fmap
`
parse
))
(
flagToList
.
fmap
display
))
,
option
[
'o'
]
[
"expose-module"
]
"Export a module from the package."
IT
.
exposedModules
...
...
Write
Preview
Markdown
is supported
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