@@ -2526,7 +2526,19 @@ parseFile stats filePath = do
25262526parseText :: StatsEnabled -> FilePath -> Text -> IO (Either String File )
25272527parseText stats filePath text = do
25282528 t1 <- getTime
2529- case HSE. parseModuleWithMode HSE. defaultParseMode {HSE. parseFilename = filePath, HSE. extensions = HSE. extensions HSE. defaultParseMode ++ [HSE. EnableExtension HSE. PatternSignatures , HSE. EnableExtension HSE. DataKinds , HSE. EnableExtension HSE. BlockArguments , HSE. EnableExtension HSE. TypeApplications , HSE. EnableExtension HSE. NamedFieldPuns ]} (Text. unpack (dropShebang text)) of
2529+ case HSE. parseModuleWithMode
2530+ HSE. defaultParseMode
2531+ { HSE. parseFilename = filePath,
2532+ HSE. extensions =
2533+ HSE. extensions HSE. defaultParseMode
2534+ ++ [ HSE. EnableExtension HSE. PatternSignatures ,
2535+ HSE. EnableExtension HSE. DataKinds ,
2536+ HSE. EnableExtension HSE. BlockArguments ,
2537+ HSE. EnableExtension HSE. TypeApplications ,
2538+ HSE. EnableExtension HSE. NamedFieldPuns
2539+ ]
2540+ }
2541+ (Text. unpack (dropShebang text)) of
25302542 HSE. ParseFailed l e -> pure $ Left $ " Parse error: " <> HSE. prettyPrint l <> " : " <> e
25312543 HSE. ParseOk ! file -> do
25322544 t2 <- getTime
@@ -2907,10 +2919,36 @@ specMain = hspec spec
29072919
29082920spec :: Spec
29092921spec = do
2922+ parseSpec
29102923 freeVariablesSpec
29112924 anyCyclesSpec
29122925 desugarTypeSpec
29132926
2927+ parseSpec :: Spec
2928+ parseSpec = do
2929+ describe " parse" do
2930+ it " dropShebang" do
2931+ r <- parseText NoStats " x.hell" " #!/bin/env hell\n x = z X {a,b}"
2932+ shouldSatisfy r Either. isRight
2933+ it " empty file parses" do
2934+ r <- parseText NoStats " x.hell" " "
2935+ shouldSatisfy r Either. isRight
2936+ it " PatternSignatures" do
2937+ r <- parseText NoStats " x.hell" " x = \\ (z :: Int) -> z"
2938+ shouldSatisfy r Either. isRight
2939+ it " TypeApplications" do
2940+ r <- parseText NoStats " x.hell" " x = z @T"
2941+ shouldSatisfy r Either. isRight
2942+ it " DataKinds" do
2943+ r <- parseText NoStats " x.hell" " x = z @\" foo\" "
2944+ shouldSatisfy r Either. isRight
2945+ it " BlockArguments" do
2946+ r <- parseText NoStats " x.hell" " x = z do y"
2947+ shouldSatisfy r Either. isRight
2948+ it " NamedFieldPuns" do
2949+ r <- parseText NoStats " x.hell" " x = z X {a,b}"
2950+ shouldSatisfy r Either. isRight
2951+
29142952anyCyclesSpec :: Spec
29152953anyCyclesSpec = do
29162954 it " anyCycles" do
0 commit comments