Skip to content

Commit 7c90e56

Browse files
committed
Fix building on ghc-7.6 (base 4.6) for purescript#713
Just add missing functions or rewrite in simple cases. Also add explicit base version requirement.
1 parent 74d7de7 commit 7c90e56

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

psc-make/Main.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ module Main where
1919
import Control.Applicative
2020
import Control.Monad.Error
2121

22-
import Data.Bool (bool)
2322
import Data.Version (showVersion)
2423

2524
import System.Console.CmdTheLine
@@ -41,7 +40,7 @@ data InputOptions = InputOptions
4140
readInput :: InputOptions -> IO [(Either P.RebuildPolicy FilePath, String)]
4241
readInput InputOptions{..} = do
4342
content <- forM ioInputFiles $ \inputFile -> (Right inputFile, ) <$> U.readFile inputFile
44-
return $ bool ((Left P.RebuildNever, P.prelude) :) id ioNoPrelude content
43+
return (if ioNoPrelude then content else (Left P.RebuildNever, P.prelude) : content)
4544

4645
newtype Make a = Make { unMake :: ErrorT String IO a } deriving (Functor, Applicative, Monad, MonadIO, MonadError String)
4746

psc/Main.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ module Main where
1919
import Control.Applicative
2020
import Control.Monad.Error
2121

22-
import Data.Bool (bool)
2322
import Data.Maybe (fromMaybe)
2423
import Data.Version (showVersion)
2524

@@ -43,7 +42,7 @@ readInput :: InputOptions -> IO [(Maybe FilePath, String)]
4342
readInput InputOptions{..}
4443
| ioUseStdIn = return . (Nothing ,) <$> getContents
4544
| otherwise = do content <- forM ioInputFiles $ \inputFile -> (Just inputFile, ) <$> U.readFile inputFile
46-
return $ bool ((Nothing, P.prelude) :) id ioNoPrelude content
45+
return (if ioNoPrelude then content else (Nothing, P.prelude) : content)
4746

4847
compile :: P.Options P.Compile -> Bool -> [FilePath] -> Maybe FilePath -> Maybe FilePath -> Bool -> IO ()
4948
compile opts stdin input output externs usePrefix = do

purescript.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ source-repository head
2424
location: https://github.com/purescript/purescript.git
2525

2626
library
27-
build-depends: base >=4 && <5,
27+
build-depends: base >=4.6 && <5,
2828
cmdtheline == 0.2.*,
2929
containers -any,
3030
unordered-containers -any,

src/Language/PureScript.hs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import Data.Time.Clock
4242
import Data.Function (on)
4343
import Data.Maybe (fromMaybe)
4444
import Data.FileEmbed (embedFile)
45-
import Data.Traversable (traverse)
4645

4746
import Control.Monad.Error
4847
import Control.Arrow ((&&&))
@@ -142,6 +141,11 @@ data RebuildPolicy
142141
-- | Always rebuild this module
143142
| RebuildAlways deriving (Show, Eq, Ord)
144143

144+
-- Traverse (Either e) instance (base 4.7)
145+
traverseEither :: Applicative f => (a -> f b) -> Either e a -> f (Either e b)
146+
traverseEither _ (Left x) = pure (Left x)
147+
traverseEither f (Right y) = Right <$> f y
148+
145149
-- |
146150
-- Compiles in "make" mode, compiling each module separately to a js files and an externs file
147151
--
@@ -163,7 +167,7 @@ make outputDir opts ms prefix = do
163167

164168
jsTimestamp <- getTimestamp jsFile
165169
externsTimestamp <- getTimestamp externsFile
166-
inputTimestamp <- traverse getTimestamp inputFile
170+
inputTimestamp <- traverseEither getTimestamp inputFile
167171

168172
return $ case (inputTimestamp, jsTimestamp, externsTimestamp) of
169173
(Right (Just t1), Just t2, Just t3) | t1 < min t2 t3 -> s

src/Language/PureScript/Sugar/CaseDeclarations.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ module Language.PureScript.Sugar.CaseDeclarations (
1919
desugarCasesModule
2020
) where
2121

22-
import Data.Either (isLeft)
2322
import Data.Monoid ((<>))
2423
import Data.List (nub, groupBy)
2524

@@ -35,6 +34,11 @@ import Language.PureScript.Supply
3534
import Language.PureScript.Traversals
3635
import Language.PureScript.TypeChecker.Monad (guardWith)
3736

37+
-- Data.Either.isLeft (base 4.7)
38+
isLeft :: Either a b -> Bool
39+
isLeft (Left _) = True
40+
isLeft (Right _) = False
41+
3842
-- |
3943
-- Replace all top-level binders in a module with case expressions.
4044
--

0 commit comments

Comments
 (0)