File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,13 @@ import HSCParser
62
62
# endif
63
63
#endif
64
64
65
+ #if MIN_VERSION_base(4,19,0)
66
+ import Data.List (unsnoc )
67
+ #else
68
+ unsnoc :: [a ] -> Maybe ([a ], a )
69
+ unsnoc = foldr (\ x -> Just . maybe ([] , x) (\ (~ (a, b)) -> (x : a, b))) Nothing
70
+ #endif
71
+
65
72
#ifdef BUILD_NHC
66
73
getDataFileName s = do here <- getCurrentDirectory
67
74
return (here++ " /" ++ s)
@@ -122,10 +129,9 @@ processFiles configM files usage = do
122
129
123
130
forM_ files (\ name -> do
124
131
(outName, outDir, outBase) <- case [f | Output f <- cFlags config] of
125
- [] -> if not (null ext) && last ext == ' c'
126
- then return (dir++ base++ init ext, dir, base)
127
- else
128
- if ext == " .hs"
132
+ [] -> case unsnoc ext of
133
+ Just (initExt, ' c' ) -> return (dir++ base++ initExt, dir, base)
134
+ _ -> if ext == " .hs"
129
135
then return (dir++ base++ " _out.hs" , dir, base)
130
136
else return (dir++ base++ " .hs" , dir, base)
131
137
where
You can’t perform that action at this time.
0 commit comments