Skip to content

Commit

Permalink
Merge branch 'bgamari-ghc-7.10-new'
Browse files Browse the repository at this point in the history
  • Loading branch information
gibiansky committed Mar 5, 2015
2 parents dc363ce + 2de62db commit 8337a1d
Show file tree
Hide file tree
Showing 21 changed files with 134 additions and 70 deletions.
35 changes: 10 additions & 25 deletions ghc-parser/generic-src/Language/Haskell/GHC/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ module Language.Haskell.GHC.Parser (
parserTypeSignature,
parserModule,
parserExpression,
partialStatement,
partialImport,
partialDeclaration,
partialTypeSignature,
partialModule,
partialExpression,

-- Haskell string preprocessing.
removeComments,
Expand Down Expand Up @@ -71,27 +65,20 @@ data Located a = Located {
} deriving (Eq, Show, Functor)


data ParserType = FullParser | PartialParser
data Parser a = Parser ParserType (P a)
data Parser a = Parser (P a)

-- Our parsers.
parserStatement = Parser FullParser Parse.fullStatement
parserImport = Parser FullParser Parse.fullImport
parserDeclaration = Parser FullParser Parse.fullDeclaration
parserExpression = Parser FullParser Parse.fullExpression
parserTypeSignature = Parser FullParser Parse.fullTypeSignature
parserModule = Parser FullParser Parse.fullModule
partialStatement = Parser PartialParser Parse.partialStatement
partialImport = Parser PartialParser Parse.partialImport
partialDeclaration = Parser PartialParser Parse.partialDeclaration
partialExpression = Parser PartialParser Parse.partialExpression
partialTypeSignature = Parser PartialParser Parse.partialTypeSignature
partialModule = Parser PartialParser Parse.partialModule
parserStatement = Parser Parse.fullStatement
parserImport = Parser Parse.fullImport
parserDeclaration = Parser Parse.fullDeclaration
parserExpression = Parser Parse.fullExpression
parserTypeSignature = Parser Parse.fullTypeSignature
parserModule = Parser Parse.fullModule

-- | Run a GHC parser on a string. Return success or failure with
-- associated information for both.
runParser :: DynFlags -> Parser a -> String -> ParseOutput a
runParser flags (Parser parserType parser) str =
runParser flags (Parser parser) str =
-- Create an initial parser state.
let filename = "<interactive>"
location = mkRealSrcLoc (mkFastString filename) 1 1
Expand All @@ -115,10 +102,8 @@ runParser flags (Parser parserType parser) str =
let parseEnd = realSrcSpanStart $ last_loc parseState
endLine = srcLocLine parseEnd
endCol = srcLocCol parseEnd
(before, after) = splitAtLoc endLine endCol str in
case parserType of
PartialParser -> Partial result (before, after)
FullParser -> Parsed result
(before, after) = splitAtLoc endLine endCol str
in Parsed result

-- Convert the bag of errors into an error string.
printErrorBag bag = joinLines . map show $ bagToList bag
Expand Down
9 changes: 6 additions & 3 deletions ghc-parser/ghc-parser.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,18 @@ library
Language.Haskell.GHC.HappyParser
-- other-modules:
-- other-extensions:
build-depends: base >=4.6 && <4.8,
ghc >=7.6 && <7.10
build-depends: base >=4.6 && <4.9,
ghc >=7.6 && <7.11

if impl(ghc >= 7.6) && impl(ghc < 7.8)
hs-source-dirs: generic-src src-7.6
else
if impl(ghc >= 7.8) && impl(ghc < 7.8.3)
hs-source-dirs: generic-src src-7.8.2
else
hs-source-dirs: generic-src src-7.8.3
if impl(ghc < 7.10)
hs-source-dirs: generic-src src-7.8.3
else
hs-source-dirs: generic-src src-7.10

default-language: Haskell2010
42 changes: 42 additions & 0 deletions ghc-parser/src-7.10/Language/Haskell/GHC/HappyParser.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module Language.Haskell.GHC.HappyParser
( fullStatement
, fullImport
, fullDeclaration
, fullExpression
, fullTypeSignature
, fullModule
) where

import Parser
import SrcLoc

-- compiler/hsSyn
import HsSyn

-- compiler/utils
import OrdList

-- compiler/parser
import RdrHsSyn
import Lexer

-- compiler/basicTypes
import RdrName

fullStatement :: P (Maybe (LStmt RdrName (LHsExpr RdrName)))
fullStatement = parseStmt

fullImport :: P (LImportDecl RdrName)
fullImport = parseImport

fullDeclaration :: P (OrdList (LHsDecl RdrName))
fullDeclaration = parseDeclaration

fullExpression :: P (LHsExpr RdrName)
fullExpression = parseExpression

fullTypeSignature :: P (Located (OrdList (LHsDecl RdrName)))
fullTypeSignature = parseTypeSignature

fullModule :: P (Located (HsModule RdrName))
fullModule = parseModule
2 changes: 1 addition & 1 deletion ihaskell-display/ihaskell-aeson/ihaskell-aeson.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ library
OverloadedStrings

-- Other library packages from which modules are imported.
build-depends: base ==4.6.* || ==4.7.*,
build-depends: base >=4.6 && <4.9,
here,
classy-prelude >=0.7,
aeson >= 0.7,
Expand Down
2 changes: 1 addition & 1 deletion ihaskell-display/ihaskell-basic/ihaskell-basic.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ library
OverloadedStrings

-- Other library packages from which modules are imported.
build-depends: base ==4.6.* || ==4.7.*,
build-depends: base >=4.6 && <4.9,
classy-prelude >=0.6,
ihaskell >= 0.5

Expand Down
2 changes: 1 addition & 1 deletion ihaskell-display/ihaskell-blaze/ihaskell-blaze.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ library
OverloadedStrings

-- Other library packages from which modules are imported.
build-depends: base ==4.6.* || ==4.7.*,
build-depends: base >=4.6 && <4.9,
classy-prelude >=0.6,
blaze-html >= 0.6,
blaze-markup >= 0.5,
Expand Down
2 changes: 1 addition & 1 deletion ihaskell-display/ihaskell-charts/ihaskell-charts.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ library
OverloadedStrings

-- Other library packages from which modules are imported.
build-depends: base ==4.6.* || ==4.7.*,
build-depends: base >=4.6 && <4.9,
classy-prelude >=0.6,
bytestring,
data-default-class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import Diagrams.Backend.Cairo

import IHaskell.Display

instance IHaskellDisplay (Diagram Cairo R2) where
instance IHaskellDisplay (QDiagram Cairo V2 Double Any) where
display renderable = do
png <- diagramData renderable PNG
svg <- diagramData renderable SVG
return $ Display [png, svg]

diagramData :: Diagram Cairo R2 -> OutputType -> IO DisplayData
diagramData :: Diagram Cairo -> OutputType -> IO DisplayData
diagramData renderable format = do
switchToTmpDir

Expand All @@ -31,7 +31,7 @@ diagramData renderable format = do

-- Write the image.
let filename = ".ihaskell-diagram." ++ extension format
renderCairo filename (Height imgHeight) renderable
renderCairo filename (mkHeight imgHeight) renderable

-- Convert to base64.
imgData <- readFile $ fpFromString filename
Expand All @@ -45,5 +45,5 @@ diagramData renderable format = do
extension PNG = "png"

-- Rendering hint.
diagram :: Diagram Cairo R2 -> Diagram Cairo R2
diagram :: Diagram Cairo -> Diagram Cairo
diagram = id
2 changes: 1 addition & 1 deletion ihaskell-display/ihaskell-diagrams/ihaskell-diagrams.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ library
OverloadedStrings

-- Other library packages from which modules are imported.
build-depends: base ==4.6.* || ==4.7.*,
build-depends: base >=4.6 && <4.9,
classy-prelude >=0.6,
bytestring,
directory,
Expand Down
2 changes: 1 addition & 1 deletion ihaskell-display/ihaskell-hatex/ihaskell-hatex.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cabal-version: >=1.16

library
exposed-modules: IHaskell.Display.Hatex
build-depends: base ==4.6.* || ==4.7.*,
build-depends: base >=4.6 && <4.9,
text,
HaTeX >= 3.9,
ihaskell >= 0.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ library
OverloadedStrings

-- Other library packages from which modules are imported.
build-depends: base ==4.6.* || ==4.7.*,
build-depends: base >=4.6 && <4.9,
classy-prelude >=0.6,
bytestring,
directory,
Expand Down
2 changes: 1 addition & 1 deletion ihaskell-display/ihaskell-magic/ihaskell-magic.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ library
OverloadedStrings

-- Other library packages from which modules are imported.
build-depends: base ==4.6.* || ==4.7.*,
build-depends: base >=4.6 && <4.9,
classy-prelude >=0.6,
magic >= 1.0.8,
text,
Expand Down
2 changes: 1 addition & 1 deletion ihaskell-display/ihaskell-parsec/ihaskell-parsec.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ library
OverloadedStrings

-- Other library packages from which modules are imported.
build-depends: base ==4.6.* || ==4.7.*,
build-depends: base >=4.6 && <4.9,
aeson >=0.7 && <0.9,
unordered-containers,
classy-prelude,
Expand Down
2 changes: 1 addition & 1 deletion ihaskell-display/ihaskell-widgets/ihaskell-widgets.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ library
OverloadedStrings

-- Other library packages from which modules are imported.
build-depends: base ==4.6.* || ==4.7.*,
build-depends: base >=4.6 && <4.9,
aeson >=0.7 && <0.9,
classy-prelude,
here,
Expand Down
23 changes: 16 additions & 7 deletions ihaskell.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@ data-files:
installation/run.sh
profile/profile.tar

flag binPkgDb
default: True
description: bin-package-db package needed (needed for GHC >= 7.10)

library
hs-source-dirs: src
default-language: Haskell2010
build-depends:
aeson >=0.6 && < 0.9,
base >=4.6 && < 4.8,
base >=4.6 && < 4.9,
base64-bytestring >=1.0,
bytestring >=0.10,
cereal >=0.3,
Expand All @@ -63,7 +67,7 @@ library
containers >=0.5,
directory -any,
filepath -any,
ghc ==7.6.* || == 7.8.*,
ghc >=7.6 || < 7.11,
ghc-parser >=0.1.4,
haskeline -any,
here ==1.2.*,
Expand Down Expand Up @@ -95,6 +99,8 @@ library
ipython-kernel >=0.3,
arithmoi ==0.4.*
-- arithmoi is fixed to avoid issues with diagrams
if flag(binPkgDb)
build-depends: bin-package-db

exposed-modules: IHaskell.Display
IHaskell.Convert
Expand Down Expand Up @@ -127,7 +133,7 @@ executable IHaskell
-- Other library packages from which modules are imported.
default-language: Haskell2010
build-depends:
base >=4.6 && < 4.8,
base >=4.6 && < 4.9,
ghc-paths ==0.1.*,
aeson >=0.6 && < 0.9,
bytestring >=0.10,
Expand All @@ -136,12 +142,14 @@ executable IHaskell
mono-traversable >=0.6,
containers >=0.5,
directory -any,
ghc ==7.6.* || == 7.8.*,
ghc >=7.6 && < 7.11,
ihaskell -any,
MissingH >=1.2,
text -any,
ipython-kernel >= 0.2,
unix >= 2.6
if flag(binPkgDb)
build-depends: bin-package-db

Test-Suite hspec
hs-source-dirs: src
Expand All @@ -151,7 +159,7 @@ Test-Suite hspec
default-language: Haskell2010
build-depends:
aeson >=0.6 && < 0.9,
base >=4.6 && < 4.8,
base >=4.6 && < 4.9,
base64-bytestring >=1.0,
bytestring >=0.10,
cereal >=0.3,
Expand All @@ -161,7 +169,7 @@ Test-Suite hspec
containers >=0.5,
directory -any,
filepath -any,
ghc ==7.6.* || == 7.8.*,
ghc >=7.6 && < 7.11,
ghc-parser >=0.1.1,
ghc-paths ==0.1.*,
haskeline -any,
Expand Down Expand Up @@ -193,7 +201,8 @@ Test-Suite hspec
vector -any,
setenv ==0.1.*,
ipython-kernel >= 0.2

if flag(binPkgDb)
build-depends: bin-package-db

default-extensions:
DoAndIfThenElse
Expand Down
4 changes: 2 additions & 2 deletions ipython-kernel/ipython-kernel.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ library
other-extensions: OverloadedStrings
hs-source-dirs: src
default-language: Haskell2010
build-depends: base >=4.6 && < 4.8,
build-depends: base >=4.6 && < 4.9,
aeson >=0.6 && < 0.9,
bytestring >=0.10,
cereal >=0.3,
Expand All @@ -57,7 +57,7 @@ executable simple-calc-example
hs-source-dirs: examples
main-is: Calc.hs
build-depends: ipython-kernel,
base >=4.6 && <4.8,
base >=4.6 && <4.9,
filepath >=1.2,
mtl >=2.1,
parsec >=3.1,
Expand Down
2 changes: 1 addition & 1 deletion src/IHaskell/BrokenPackages.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{-# LANGUAGE OverloadedStrings, NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings, NoImplicitPrelude, FlexibleContexts #-}
module IHaskell.BrokenPackages (getBrokenPackages) where

import ClassyPrelude hiding ((<|>))
Expand Down
Loading

0 comments on commit 8337a1d

Please sign in to comment.