summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilFreeman <>2014-11-19 23:37:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2014-11-19 23:37:00 (GMT)
commita1cc4a093cf938a1d8a20046e88141543df18ec9 (patch)
tree3652fda95e43d63f967faa1b7ca96fcfeaf43402
parentf12ebae7a4a7e9911b9efc36b2205fd173df4f05 (diff)
version 0.6.1.10.6.1.1
-rw-r--r--examples/passing/Guards.purs6
-rw-r--r--examples/passing/Operators.purs4
-rw-r--r--prelude/prelude.purs20
-rw-r--r--psc-make/Main.hs3
-rw-r--r--psc/Main.hs3
-rw-r--r--purescript.cabal4
-rw-r--r--src/Language/PureScript.hs8
-rw-r--r--src/Language/PureScript/Constants.hs12
-rw-r--r--src/Language/PureScript/Optimizer/Inliner.hs6
-rw-r--r--src/Language/PureScript/Parser/Common.hs2
-rw-r--r--src/Language/PureScript/Parser/Declarations.hs12
-rw-r--r--src/Language/PureScript/Sugar/CaseDeclarations.hs6
12 files changed, 51 insertions, 35 deletions
diff --git a/examples/passing/Guards.purs b/examples/passing/Guards.purs
index 1dce0f1..22d4999 100644
--- a/examples/passing/Guards.purs
+++ b/examples/passing/Guards.purs
@@ -20,4 +20,10 @@ module Main where
_ | m < n -> n
| otherwise -> m
+ testIndentation :: Number -> Number -> Number
+ testIndentation x y | x > 0
+ = x + y
+ | otherwise
+ = y - x
+
main = Debug.Trace.trace $ min "Done" "ZZZZ"
diff --git a/examples/passing/Operators.purs b/examples/passing/Operators.purs
index ab3bcbc..3911c72 100644
--- a/examples/passing/Operators.purs
+++ b/examples/passing/Operators.purs
@@ -61,6 +61,9 @@ module Main where
test15 :: Number -> Number -> Boolean
test15 a b = const false $ a `test14` b
+ test16 :: Number -> Number -> Number
+ test16 x y = x .|. y .&. y
+
main = do
let t1 = test1 1 2 (\x y -> x + y)
let t2 = test2
@@ -77,4 +80,5 @@ module Main where
let t13 = test13 k 1 2
let t14 = test14 1 2
let t15 = test15 1 2
+ let t16 = test16 1 2
trace "Done"
diff --git a/prelude/prelude.purs b/prelude/prelude.purs
index 65c37c5..54c96f8 100644
--- a/prelude/prelude.purs
+++ b/prelude/prelude.purs
@@ -17,7 +17,7 @@ module Prelude
, negate
, Eq, (==), (/=), refEq, refIneq
, Ord, Ordering(..), compare, (<), (>), (<=), (>=)
- , Bits, (&), (|), (^), shl, shr, zshr, complement
+ , Bits, (.&.), (.|.), (.^.), shl, shr, zshr, complement
, BoolLike, (&&), (||)
, not
, Semigroup, (<>), (++)
@@ -372,14 +372,14 @@ module Prelude
EQ -> compare xs ys
other -> other
- infixl 10 &
- infixl 10 |
- infixl 10 ^
+ infixl 10 .&.
+ infixl 10 .|.
+ infixl 10 .^.
class Bits b where
- (&) :: b -> b -> b
- (|) :: b -> b -> b
- (^) :: b -> b -> b
+ (.&.) :: b -> b -> b
+ (.|.) :: b -> b -> b
+ (.^.) :: b -> b -> b
shl :: b -> Number -> b
shr :: b -> Number -> b
zshr :: b -> Number -> b
@@ -426,9 +426,9 @@ module Prelude
\}" :: Number -> Number
instance bitsNumber :: Bits Number where
- (&) = numAnd
- (|) = numOr
- (^) = numXor
+ (.&.) = numAnd
+ (.|.) = numOr
+ (.^.) = numXor
shl = numShl
shr = numShr
zshr = numZshr
diff --git a/psc-make/Main.hs b/psc-make/Main.hs
index 3753377..f56efb5 100644
--- a/psc-make/Main.hs
+++ b/psc-make/Main.hs
@@ -19,7 +19,6 @@ module Main where
import Control.Applicative
import Control.Monad.Error
-import Data.Bool (bool)
import Data.Version (showVersion)
import System.Console.CmdTheLine
@@ -41,7 +40,7 @@ data InputOptions = InputOptions
readInput :: InputOptions -> IO [(Either P.RebuildPolicy FilePath, String)]
readInput InputOptions{..} = do
content <- forM ioInputFiles $ \inputFile -> (Right inputFile, ) <$> U.readFile inputFile
- return $ bool ((Left P.RebuildNever, P.prelude) :) id ioNoPrelude content
+ return (if ioNoPrelude then content else (Left P.RebuildNever, P.prelude) : content)
newtype Make a = Make { unMake :: ErrorT String IO a } deriving (Functor, Applicative, Monad, MonadIO, MonadError String)
diff --git a/psc/Main.hs b/psc/Main.hs
index b6a7a12..2a1d594 100644
--- a/psc/Main.hs
+++ b/psc/Main.hs
@@ -19,7 +19,6 @@ module Main where
import Control.Applicative
import Control.Monad.Error
-import Data.Bool (bool)
import Data.Maybe (fromMaybe)
import Data.Version (showVersion)
@@ -43,7 +42,7 @@ readInput :: InputOptions -> IO [(Maybe FilePath, String)]
readInput InputOptions{..}
| ioUseStdIn = return . (Nothing ,) <$> getContents
| otherwise = do content <- forM ioInputFiles $ \inputFile -> (Just inputFile, ) <$> U.readFile inputFile
- return $ bool ((Nothing, P.prelude) :) id ioNoPrelude content
+ return (if ioNoPrelude then content else (Nothing, P.prelude) : content)
compile :: P.Options P.Compile -> Bool -> [FilePath] -> Maybe FilePath -> Maybe FilePath -> Bool -> IO ()
compile opts stdin input output externs usePrefix = do
diff --git a/purescript.cabal b/purescript.cabal
index b5094a7..59662dd 100644
--- a/purescript.cabal
+++ b/purescript.cabal
@@ -1,5 +1,5 @@
name: purescript
-version: 0.6.1
+version: 0.6.1.1
cabal-version: >=1.8
build-type: Simple
license: MIT
@@ -24,7 +24,7 @@ source-repository head
location: https://github.com/purescript/purescript.git
library
- build-depends: base >=4 && <5,
+ build-depends: base >=4.6 && <5,
cmdtheline == 0.2.*,
containers -any,
unordered-containers -any,
diff --git a/src/Language/PureScript.hs b/src/Language/PureScript.hs
index 92b5963..4a516d4 100644
--- a/src/Language/PureScript.hs
+++ b/src/Language/PureScript.hs
@@ -42,7 +42,6 @@ import Data.Time.Clock
import Data.Function (on)
import Data.Maybe (fromMaybe)
import Data.FileEmbed (embedFile)
-import Data.Traversable (traverse)
import Control.Monad.Error
import Control.Arrow ((&&&))
@@ -142,6 +141,11 @@ data RebuildPolicy
-- | Always rebuild this module
| RebuildAlways deriving (Show, Eq, Ord)
+-- Traverse (Either e) instance (base 4.7)
+traverseEither :: Applicative f => (a -> f b) -> Either e a -> f (Either e b)
+traverseEither _ (Left x) = pure (Left x)
+traverseEither f (Right y) = Right <$> f y
+
-- |
-- Compiles in "make" mode, compiling each module separately to a js files and an externs file
--
@@ -163,7 +167,7 @@ make outputDir opts ms prefix = do
jsTimestamp <- getTimestamp jsFile
externsTimestamp <- getTimestamp externsFile
- inputTimestamp <- traverse getTimestamp inputFile
+ inputTimestamp <- traverseEither getTimestamp inputFile
return $ case (inputTimestamp, jsTimestamp, externsTimestamp) of
(Right (Just t1), Just t2, Just t3) | t1 < min t2 t3 -> s
diff --git a/src/Language/PureScript/Constants.hs b/src/Language/PureScript/Constants.hs
index 8ef5e38..2c0d5ae 100644
--- a/src/Language/PureScript/Constants.hs
+++ b/src/Language/PureScript/Constants.hs
@@ -65,14 +65,14 @@ module Language.PureScript.Constants where
(/=) :: String
(/=) = "/="
-(&) :: String
-(&) = "&"
+(.&.) :: String
+(.&.) = ".&."
-bar :: String
-bar = "|"
+(.|.) :: String
+(.|.) = ".|."
-(^) :: String
-(^) = "^"
+(.^.) :: String
+(.^.) = ".^."
(&&) :: String
(&&) = "&&"
diff --git a/src/Language/PureScript/Optimizer/Inliner.hs b/src/Language/PureScript/Optimizer/Inliner.hs
index a097e77..a5f1244 100644
--- a/src/Language/PureScript/Optimizer/Inliner.hs
+++ b/src/Language/PureScript/Optimizer/Inliner.hs
@@ -117,9 +117,9 @@ inlineCommonOperators = applyAll $
, binaryFunction C.bitsNumber C.shl ShiftLeft
, binaryFunction C.bitsNumber C.shr ShiftRight
, binaryFunction C.bitsNumber C.zshr ZeroFillShiftRight
- , binary C.bitsNumber (C.&) BitwiseAnd
- , binary C.bitsNumber C.bar BitwiseOr
- , binary C.bitsNumber (C.^) BitwiseXor
+ , binary C.bitsNumber (C..&.) BitwiseAnd
+ , binary C.bitsNumber (C..|.) BitwiseOr
+ , binary C.bitsNumber (C..^.) BitwiseXor
, unary C.bitsNumber C.complement BitwiseNot
, binary C.boolLikeBoolean (C.&&) And
diff --git a/src/Language/PureScript/Parser/Common.hs b/src/Language/PureScript/Parser/Common.hs
index feb9e12..0aac9de 100644
--- a/src/Language/PureScript/Parser/Common.hs
+++ b/src/Language/PureScript/Parser/Common.hs
@@ -71,7 +71,7 @@ reservedTypeNames = [ "forall"
-- A list of reserved operators
--
reservedOpNames :: [String]
-reservedOpNames = [ "=>", "->", "=", ".", "\\" ]
+reservedOpNames = [ "=>", "->", "=", ".", "\\", "|" ]
-- |
-- Valid first characters for an identifier
diff --git a/src/Language/PureScript/Parser/Declarations.hs b/src/Language/PureScript/Parser/Declarations.hs
index 676e014..0b7c371 100644
--- a/src/Language/PureScript/Parser/Declarations.hs
+++ b/src/Language/PureScript/Parser/Declarations.hs
@@ -83,9 +83,9 @@ parseValueDeclaration = do
name <- parseIdent
binders <- P.many parseBinderNoParens
value <- Left <$> (C.indented *>
- C.mark (P.many1 ((,) <$> (C.same *> parseGuard)
- <*> (lexeme (indented *> P.char '=') *> parseValueWithWhereClause)
- )))
+ P.many1 ((,) <$> parseGuard
+ <*> (lexeme (indented *> P.char '=') *> parseValueWithWhereClause)
+ ))
<|> Right <$> (lexeme (indented *> P.char '=') *> parseValueWithWhereClause)
return $ ValueDeclaration name Value binders value
where
@@ -304,9 +304,9 @@ parseCase = Case <$> P.between (P.try (C.reserved "case")) (C.indented *> C.rese
parseCaseAlternative :: P.Parsec String ParseState CaseAlternative
parseCaseAlternative = CaseAlternative <$> (return <$> parseBinder)
<*> (Left <$> (C.indented *>
- C.mark (P.many1 ((,) <$> (C.same *> parseGuard)
- <*> (lexeme (indented *> C.reservedOp "->") *> parseValue)
- )))
+ P.many1 ((,) <$> parseGuard
+ <*> (lexeme (indented *> C.reservedOp "->") *> parseValue)
+ ))
<|> Right <$> (lexeme (indented *> C.reservedOp "->") *> parseValue))
P.<?> "case alternative"
diff --git a/src/Language/PureScript/Sugar/CaseDeclarations.hs b/src/Language/PureScript/Sugar/CaseDeclarations.hs
index 0c47031..5417e2e 100644
--- a/src/Language/PureScript/Sugar/CaseDeclarations.hs
+++ b/src/Language/PureScript/Sugar/CaseDeclarations.hs
@@ -19,7 +19,6 @@ module Language.PureScript.Sugar.CaseDeclarations (
desugarCasesModule
) where
-import Data.Either (isLeft)
import Data.Monoid ((<>))
import Data.List (nub, groupBy)
@@ -35,6 +34,11 @@ import Language.PureScript.Supply
import Language.PureScript.Traversals
import Language.PureScript.TypeChecker.Monad (guardWith)
+-- Data.Either.isLeft (base 4.7)
+isLeft :: Either a b -> Bool
+isLeft (Left _) = True
+isLeft (Right _) = False
+
-- |
-- Replace all top-level binders in a module with case expressions.
--