haskell-src-exts 1.11.1 → 1.12.0
raw patch · 11 files changed
+76/−26 lines, 11 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Language.Haskell.Exts.Extension: ExplicitForall :: Extension
+ Language.Haskell.Exts.Extension: ExplicitForAll :: Extension
Files
- CHANGELOG +14/−0
- Test/examples/IfThenElseLayout.hs +11/−0
- Test/examples/QuasiQuoteLines.hs +1/−1
- Test/failing.txt +5/−3
- Test/printFail.txt +4/−1
- haskell-src-exts.cabal +2/−1
- src/Language/Haskell/Exts/Annotated/ExactPrint.hs +1/−1
- src/Language/Haskell/Exts/Extension.hs +8/−7
- src/Language/Haskell/Exts/Lexer.hs +6/−3
- src/Language/Haskell/Exts/ParseUtils.hs +22/−7
- src/Language/Haskell/Exts/Pretty.hs +2/−2
CHANGELOG view
@@ -1,3 +1,17 @@+** 1.12.x + +1.11.1 --> 1.12.0 +=============== + +* Move from old [$...| quasi-quote syntax to the new [...| one. + The old syntax is still recognized while parsing. + +* Allow symbols as variables when TypeOperators is enabled. + +* Rename ExplicitForall in ExplicitForAll, to be consistent + with GHC and the Haskell' process. + + ** 1.11.x 1.10.2 --> 1.11.1
+ Test/examples/IfThenElseLayout.hs view
@@ -0,0 +1,11 @@+module IfThenElseLayout where++askCardsForExchange :: Hand -> IO [Card]+askCardsForExchange h = do+ putStrLn "Wich card do you want to exchange? (Max. 3)"+ response <- getLine+ if length (readCards response) > 3 || not (all (flip elem h) h) then+ askCardsForExchange h+ else+ return (readCards response)+
Test/examples/QuasiQuoteLines.hs view
@@ -3,7 +3,7 @@ import Here str :: String-str = [$here|test +str = [here|test test test test |]
Test/failing.txt view
@@ -1,3 +1,5 @@-Unicode.hs Fails if readFile is not Unicode-aware, i.e. if GHC 6.12 is not used. -UnicodeSyntax.hs Same as above. -ForeignImport.hs Shouldn't succeed. Lacks ForeignFunctionInterface pragma, but complains about missing TemplateHaskell.+IfThenElseLayout.hs New layout rules for if-then-else not yet supported. +GADTRecord.hs GADT records not yet supported. +DoRec.hs DoRec not yet supported. +ForeignImport.hs Shouldn't succeed. Lacks ForeignFunctionInterface pragma, but complains about missing TemplateHaskell. +CStyleLinePragmas.hs Shouldn't succeed. HSE does not and will not support C-style line pragmas.
Test/printFail.txt view
@@ -1,3 +1,6 @@ HexPrec.hs Uses hexadecimal notation to specify precedence of infix operator. We don't retain that info. RealGHC.lhs Literate haskell. -SpecializeInstance.hs Prints SPECIALISE instead of SPECIALIZE.+SpecializeInstance.hs Prints SPECIALISE instead of SPECIALIZE. +Unicode.hs Printing is not Unicode-aware. +UnicodeSyntax.hs Printing is not Unicode-aware. +QuasiQuoteOld.hs Exact printer always uses new quasi-quote syntax.
haskell-src-exts.cabal view
@@ -1,5 +1,5 @@ Name: haskell-src-exts-Version: 1.11.1+Version: 1.12.0 License: BSD3 License-File: LICENSE Author: Niklas Broberg@@ -62,6 +62,7 @@ Test/examples/HexPrec.hs Test/examples/Hyphen.hs Test/examples/ImportSymbol.hs+ Test/examples/IfThenElseLayout.hs Test/examples/IndentedWhere.hs Test/examples/InfixParser.hs Test/examples/LanguagePragma.hs
src/Language/Haskell/Exts/Annotated/ExactPrint.hs view
@@ -1251,7 +1251,7 @@ SpliceExp l sp -> exactP sp QuasiQuote l name qt -> do let qtLines = lines qt - printString $ "[$" ++ name ++ "|" + printString $ "[" ++ name ++ "|" sequence_ (intersperse newLine $ map printString qtLines) printString "|]" XTag l xn attrs mat es ->
src/Language/Haskell/Exts/Extension.hs view
@@ -36,7 +36,7 @@ | MultiParamTypeClasses | NoMonomorphismRestriction | FunctionalDependencies - | ExplicitForall + | ExplicitForAll | Rank2Types | RankNTypes | PolymorphicComponents @@ -118,13 +118,14 @@ implE e = case e of TypeFamilies -> [KindSignatures] - ScopedTypeVariables -> [TypeOperators, ExplicitForall] + ScopedTypeVariables -> [TypeOperators, ExplicitForAll] XmlSyntax -> [RegularPatterns] RegularPatterns -> [PatternGuards] - RankNTypes -> [Rank2Types] - Rank2Types -> [PolymorphicComponents] - PolymorphicComponents -> [ExplicitForall] - LiberalTypeSynonyms -> [ExplicitForall] + RankNTypes -> [Rank2Types, ExplicitForAll] + Rank2Types -> [PolymorphicComponents, ExplicitForAll] + PolymorphicComponents -> [ExplicitForAll] + LiberalTypeSynonyms -> [ExplicitForAll] + ExistentialQuantification -> [ExplicitForAll] -- Deprecations RecordPuns -> [NamedFieldPuns] PatternSignatures -> [ScopedTypeVariables] @@ -178,7 +179,7 @@ , MultiParamTypeClasses , NoMonomorphismRestriction , FunctionalDependencies - , ExplicitForall + , ExplicitForAll , Rank2Types , RankNTypes , PolymorphicComponents
src/Language/Haskell/Exts/Lexer.hs view
@@ -228,7 +228,7 @@ special_varops :: [(String,(Token, Maybe ExtScheme))] special_varops = [ -- the dot is only a special symbol together with forall, but can still be used as function composition- ( ".", (Dot, Just (Any [ExplicitForall, ExistentialQuantification])) ),+ ( ".", (Dot, Just (Any [ExplicitForAll, ExistentialQuantification])) ), ( "-", (Minus, Nothing) ), ( "!", (Exclamation, Nothing) ) ]@@ -245,7 +245,7 @@ ( "do", (KW_Do, Nothing) ), ( "else", (KW_Else, Nothing) ), ( "family", (KW_Family, Just (Any [TypeFamilies])) ), -- indexed type families- ( "forall", (KW_Forall, Just (Any [ExplicitForall, ExistentialQuantification])) ), -- universal/existential quantification+ ( "forall", (KW_Forall, Just (Any [ExplicitForAll, ExistentialQuantification])) ), -- universal/existential quantification ( "group", (KW_Group, Just (Any [TransformListComp])) ), ( "if", (KW_If, Nothing) ), ( "import", (KW_Import, Nothing) ),@@ -270,7 +270,7 @@ ( "foreign", (KW_Foreign, Just (Any [ForeignFunctionInterface])) ), -- Unicode- ( "\x2200", (KW_Forall, Just (All [UnicodeSyntax, ExplicitForall])) )+ ( "\x2200", (KW_Forall, Just (All [UnicodeSyntax, ExplicitForAll])) ) ] @@ -631,6 +631,9 @@ return THTypQuote '[':'$':c:_ | isLower c && QuasiQuotes `elem` exts -> discard 2 >> lexQuasiQuote++ '[':c:s | isLower c && QuasiQuotes `elem` exts && case dropWhile isIdent s of { '|':_ -> True;_->False} ->+ discard 1 >> lexQuasiQuote '|':']':_ | TemplateHaskell `elem` exts -> do discard 2
src/Language/Haskell/Exts/ParseUtils.hs view
@@ -234,10 +234,16 @@ return (Nothing,dh) checkSimple :: String -> PType L -> [TyVarBind L] -> P (DeclHead L)-checkSimple kw (TyApp _ l t) xs | isTyVarBind t = checkSimple kw l (toTyVarBind t : xs)-checkSimple _ (TyInfix l t1 (UnQual _ t) t2) []- | isTyVarBind t1 && isTyVarBind t2 =- checkEnabled TypeOperators >> return (DHInfix l (toTyVarBind t1) t (toTyVarBind t2))+--checkSimple kw (TyApp _ l t) xs | isTyVarBind t = checkSimple kw l (toTyVarBind t : xs)++checkSimple kw (TyApp _ l t) xs = do+ tvb <- mkTyVarBind t+ checkSimple kw l (tvb : xs)+checkSimple _ (TyInfix l t1 (UnQual _ t) t2) [] = do+ checkEnabled TypeOperators+ tv1 <- mkTyVarBind t1+ tv2 <- mkTyVarBind t2+ return (DHInfix l tv1 t tv2) checkSimple _kw (TyCon l (UnQual _ t)) xs = do case t of Symbol _ _ -> checkEnabled TypeOperators@@ -246,16 +252,25 @@ checkSimple kw (TyParen l t) xs = do dh <- checkSimple kw t xs return (DHParen l dh)-checkSimple kw _ _ = fail ("Illegal " ++ kw ++ " declaration")+checkSimple kw l _ = fail ("Illegal " ++ kw ++ " declaration:" ++ show (fmap (const ()) l)) +mkTyVarBind :: PType L -> P (TyVarBind L)+mkTyVarBind (TyVar l n) = return $ UnkindedVar l n+mkTyVarBind (TyKind l (TyVar _ n) k) = return $ KindedVar l n k+mkTyVarBind (TyCon l (UnQual _ n@(Symbol _ _))) = checkEnabled TypeOperators >> return (UnkindedVar l n)+mkTyVarBind (TyKind l (TyCon _ (UnQual _ n@(Symbol _ _))) k) = checkEnabled TypeOperators >> return (KindedVar l n k)++{- isTyVarBind :: PType L -> Bool isTyVarBind (TyVar _ _) = True+--isTyVarBind (TyCon _ (UnQual _ n@(Symbol _ _))) = True isTyVarBind (TyKind _ (TyVar _ _) _) = True isTyVarBind _ = False toTyVarBind :: PType L -> TyVarBind L toTyVarBind (TyVar l n) = UnkindedVar l n toTyVarBind (TyKind l (TyVar _ n) k) = KindedVar l n k+-} checkInstHeader :: PType L -> P (Maybe (S.Context L), InstHead L) checkInstHeader (TyForall _ Nothing cs t) = do@@ -876,11 +891,11 @@ checkT :: PType L -> Bool -> P (S.Type L) checkT t simple = case t of TyForall l tvs@Nothing cs pt -> do- when (simple) $ checkEnabled ExplicitForall+ when (simple) $ checkEnabled ExplicitForAll ctxt <- checkContext cs check1Type pt (S.TyForall l Nothing ctxt) TyForall l tvs cs pt -> do- checkEnabled ExplicitForall+ checkEnabled ExplicitForAll ctxt <- checkContext cs check1Type pt (S.TyForall l tvs ctxt) TyFun l at rt -> check2Types at rt (S.TyFun l)
src/Language/Haskell/Exts/Pretty.hs view
@@ -767,7 +767,7 @@ prettyPrec p (NegApp e) = parensIf (p > 0) $ char '-' <> prettyPrec 4 e prettyPrec p (App a b) = parensIf (p > 3) $ myFsep [prettyPrec 3 a, prettyPrec 4 b] prettyPrec p (Lambda _loc patList ppBody) = parensIf (p > 1) $ myFsep $- char '\\' : map pretty patList ++ [text "->", pretty ppBody]+ char '\\' : map (prettyPrec 2) patList ++ [text "->", pretty ppBody] -- keywords -- two cases for lets prettyPrec p (Let (BDecls declList) letBody) =@@ -825,7 +825,7 @@ prettyPrec _ (SpliceExp s) = pretty s prettyPrec _ (TypQuote t) = text "\'\'" <> pretty t prettyPrec _ (VarQuote x) = text "\'" <> pretty x- prettyPrec _ (QuasiQuote n qt) = text ("[$" ++ n ++ "|" ++ qt ++ "|]")+ prettyPrec _ (QuasiQuote n qt) = text ("[" ++ n ++ "|" ++ qt ++ "|]") -- Hsx prettyPrec _ (XTag _ n attrs mattr cs) = let ax = maybe [] (return . pretty) mattr