Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
Packages
Cabal
Commits
c8e8f052
Commit
c8e8f052
authored
Mar 05, 2008
by
Duncan Coutts
Browse files
Add read/show for CompilerFlavour like for OS and Arch
Also add YHC compiler flavour.
parent
e9ea7591
Changes
1
Show whitespace changes
Inline
Side-by-side
Distribution/Compiler.hs
View file @
c8e8f052
...
...
@@ -39,18 +39,45 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
module
Distribution.Compiler
(
CompilerFlavor
(
..
),
defaultCompilerFlavor
)
where
module
Distribution.Compiler
(
CompilerFlavor
(
..
),
showCompilerFlavor
,
readCompilerFlavor
,
buildCompilerFlavor
,
defaultCompilerFlavor
)
where
import
System.Info
(
compilerName
)
import
qualified
System.Info
(
compilerName
)
import
qualified
Data.Char
as
Char
(
toLower
)
data
CompilerFlavor
=
GHC
|
NHC
|
Hugs
|
HBC
|
Helium
|
JHC
|
OtherCompiler
String
data
CompilerFlavor
=
GHC
|
NHC
|
YHC
|
Hugs
|
HBC
|
Helium
|
JHC
|
OtherCompiler
String
deriving
(
Show
,
Read
,
Eq
,
Ord
)
knownCompilerFlavors
::
[
CompilerFlavor
]
knownCompilerFlavors
=
[
GHC
,
NHC
,
YHC
,
Hugs
,
HBC
,
Helium
,
JHC
]
showCompilerFlavor
::
CompilerFlavor
->
String
showCompilerFlavor
(
OtherCompiler
name
)
=
name
showCompilerFlavor
NHC
=
"nhc98"
showCompilerFlavor
other
=
lowercase
(
show
other
)
readCompilerFlavor
::
String
->
CompilerFlavor
readCompilerFlavor
s
=
case
lookup
(
lowercase
s
)
compilerMap
of
Just
arch
->
arch
Nothing
->
OtherCompiler
(
lowercase
s
)
where
compilerMap
=
[
(
showCompilerFlavor
compiler
,
compiler
)
|
compiler
<-
knownCompilerFlavors
]
buildCompilerFlavor
::
CompilerFlavor
buildCompilerFlavor
=
readCompilerFlavor
System
.
Info
.
compilerName
defaultCompilerFlavor
::
Maybe
CompilerFlavor
defaultCompilerFlavor
=
case
c
ompiler
Name
of
"ghc"
->
Just
GHC
"nhc98"
->
Just
NHC
"jhc"
->
Just
JHC
"hugs"
->
Just
Hugs
_
->
Nothing
defaultCompilerFlavor
=
case
buildC
ompiler
Flavor
of
OtherCompiler
_
->
Nothing
_
->
Just
buildCompilerFlavor
lowercase
::
String
->
String
lowercase
=
map
Char
.
toLower
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