@@ -39,8 +39,8 @@ compileFromTo config filein fileout = do
3939 (compileFromToAndGenerateHtml config filein)
4040 fileout
4141 case result of
42- Right out -> maybe (putStrLn out) (flip writeFile out) fileout
43- Left err -> error $ showCompileError $ err
42+ Right out -> maybe (putStrLn out) (` writeFile` out) fileout
43+ Left err -> error $ showCompileError err
4444
4545-- | Compile the given file and write to the output, also generate any HTML.
4646compileFromToAndGenerateHtml :: CompileConfig -> FilePath -> FilePath -> IO (Either CompileError String )
@@ -54,7 +54,7 @@ compileFromToAndGenerateHtml config filein fileout = do
5454 , " <html>"
5555 , " <head>"
5656 ," <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>"
57- , unlines . map (" " ++ ) . map makeScriptTagSrc $ configHtmlJSLibs config
57+ , unlines . map (( " " ++ ) . makeScriptTagSrc) $ configHtmlJSLibs config
5858 , " " ++ makeScriptTagSrc relativeJsPath
5959 , " </script>"
6060 , " </head>"
@@ -64,14 +64,12 @@ compileFromToAndGenerateHtml config filein fileout = do
6464 return (Right out)
6565 where relativeJsPath = makeRelative (dropFileName fileout) fileout
6666 makeScriptTagSrc :: FilePath -> String
67- makeScriptTagSrc = \ s ->
68- " <script type=\" text/javascript\" src=\" " ++ s ++ " \" ></script>"
67+ makeScriptTagSrc s = " <script type=\" text/javascript\" src=\" " ++ s ++ " \" ></script>"
6968 Left err -> return (Left err)
7069
7170-- | Compile the given file.
7271compileFile :: CompileConfig -> FilePath -> IO (Either CompileError String )
73- compileFile config filein = do
74- either Left (Right . fst ) <$> compileFileWithState config filein
72+ compileFile config filein = either Left (Right . fst ) <$> compileFileWithState config filein
7573
7674-- | Compile a file returning the state.
7775compileFileWithState :: CompileConfig -> FilePath -> IO (Either CompileError (String ,CompileState ))
@@ -89,16 +87,16 @@ compileToModule :: (Show from,Show to,CompilesTo from to)
8987 -> IO (Either CompileError (String ,CompileState ))
9088compileToModule filepath config raw with hscode = do
9189 result <- compileViaStr filepath config with hscode
92- case result of
93- Left err -> return ( Left err)
94- Right (PrintState {.. },state,_) -> do
95- return $ Right ( generateWrapped (concat $ reverse psOutput)
96- (stateModuleName state)
97- , state
98- )
90+ return $ case result of
91+ Left err -> Left err
92+ Right (PrintState {.. },state,_) ->
93+ Right ( generateWrapped (concat $ reverse psOutput)
94+ (stateModuleName state)
95+ , state
96+ )
9997 where
10098 generateWrapped jscode (ModuleName modulename) =
101- unlines $ filter (not . null ) $
99+ unlines $ filter (not . null )
102100 [if configExportRuntime config then raw else " "
103101 ,jscode
104102 ," // Exports"
0 commit comments