git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Infix function declarations #311
43463a8Phil Freeman
prelude/prelude.purs+3−3
@@ -139,8 +139,8 @@ module Prelude where
139 (%) = numMod
139 (%) = numMod
140 negate = numNegate
140 negate = numNegate
141
141
142− infixl 4 ==
142+ infix 4 ==
143− infixl 4 /=
143+ infix 4 /=
144
144
145 class Eq a where
145 class Eq a where
146 (==) :: a -> a -> Boolean
146 (==) :: a -> a -> Boolean
@@ -343,7 +343,7 @@ module Data.Eq where
343 instance eqRef :: Eq (Ref a) where
343 instance eqRef :: Eq (Ref a) where
344 (==) = liftRef refEq
344 (==) = liftRef refEq
345 (/=) = liftRef refIneq
345 (/=) = liftRef refIneq
346−
346+
347module Control.Monad.Eff where
347module Control.Monad.Eff where
348
348
349 foreign import data Eff :: # ! -> * -> *
349 foreign import data Eff :: # ! -> * -> *
src/Language/PureScript/Declarations.hs+2−1
@@ -33,11 +33,12 @@ type Precedence = Integer
33-- |
33-- |
34-- Associativity for infix operators
34-- Associativity for infix operators
35--
35--
36−data Associativity = Infixl | Infixr deriving (D.Data, D.Typeable)
36+data Associativity = Infixl | Infixr | Infix deriving (D.Data, D.Typeable)
37
37
38instance Show Associativity where
38instance Show Associativity where
39 show Infixl = "infixl"
39 show Infixl = "infixl"
40 show Infixr = "infixr"
40 show Infixr = "infixr"
41+ show Infix = "infix"
41
42
42-- |
43-- |
43-- Fixity data for infix operators
44-- Fixity data for infix operators
src/Language/PureScript/Parser/Common.hs+1
@@ -36,6 +36,7 @@ reservedPsNames = [ "data"
36 , "import"
36 , "import"
37 , "infixl"
37 , "infixl"
38 , "infixr"
38 , "infixr"
39+ , "infix"
39 , "class"
40 , "class"
40 , "instance"
41 , "instance"
41 , "module"
42 , "module"
src/Language/PureScript/Parser/Declarations.hs+7−1
@@ -32,6 +32,11 @@ import Language.PureScript.Parser.Kinds
32import Language.PureScript.CodeGen.JS.AST
32import Language.PureScript.CodeGen.JS.AST
33import Language.PureScript.Environment
33import Language.PureScript.Environment
34
34
35+import qualified Text.Parsec.Expr as P
36+
37+import qualified Language.PureScript.Parser.Common as C
38+import qualified Text.Parsec as P
39+
35parseDataDeclaration :: P.Parsec String ParseState Declaration
40parseDataDeclaration :: P.Parsec String ParseState Declaration
36parseDataDeclaration = do
41parseDataDeclaration = do
37 reserved "data"
42 reserved "data"
@@ -83,7 +88,8 @@ parseExternDeclaration = P.try (reserved "foreign") *> indented *> reserved "imp
83parseAssociativity :: P.Parsec String ParseState Associativity
88parseAssociativity :: P.Parsec String ParseState Associativity
84parseAssociativity =
89parseAssociativity =
85 (P.try (reserved "infixl") >> return Infixl) <|>
90 (P.try (reserved "infixl") >> return Infixl) <|>
86− (P.try (reserved "infixr") >> return Infixr)
91+ (P.try (reserved "infixr") >> return Infixr) <|>
92+ (P.try (reserved "infix") >> return Infix)
87
93
88parseFixity :: P.Parsec String ParseState Fixity
94parseFixity :: P.Parsec String ParseState Fixity
89parseFixity = Fixity <$> parseAssociativity <*> (indented *> natural)
95parseFixity = Fixity <$> parseAssociativity <*> (indented *> natural)
src/Language/PureScript/Sugar/Operators.hs+1
@@ -107,6 +107,7 @@ matchOperators ops = parseChains
107toAssoc :: Associativity -> P.Assoc
107toAssoc :: Associativity -> P.Assoc
108toAssoc Infixl = P.AssocLeft
108toAssoc Infixl = P.AssocLeft
109toAssoc Infixr = P.AssocRight
109toAssoc Infixr = P.AssocRight
110+toAssoc Infix = P.AssocNone
110
111
111token :: (P.Stream s Identity t, Show t) => (t -> Maybe a) -> P.Parsec s u a
112token :: (P.Stream s Identity t, Show t) => (t -> Maybe a) -> P.Parsec s u a
112token = P.token show (const (P.initialPos ""))
113token = P.token show (const (P.initialPos ""))