git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Infix function declarations #311
commit43463a86137a0e1ff95e232edbe621b0c8312022 authorPhil Freeman <paf31@cantab.net> dateSun 23 Mar 2014, 15:21 (13 years ago) parentf8da0b9
5 files changed+14−5
prelude/prelude.purs+3−3 src/Language/PureScript/Declarations.hs+2−1 src/Language/PureScript/Parser/Common.hs+1 src/Language/PureScript/Parser/Declarations.hs+7−1 src/Language/PureScript/Sugar/Operators.hs+1
prelude/prelude.purs+3−3
@@ -139,8 +139,8 @@ module Prelude where
139139 (%) = numMod
140140 negate = numNegate
141141
142− infixl 4 ==
143− infixl 4 /=
142+ infix 4 ==
143+ infix 4 /=
144144
145145 class Eq a where
146146 (==) :: a -> a -> Boolean
@@ -343,7 +343,7 @@ module Data.Eq where
343343 instance eqRef :: Eq (Ref a) where
344344 (==) = liftRef refEq
345345 (/=) = liftRef refIneq
346−
346+
347347module Control.Monad.Eff where
348348
349349 foreign import data Eff :: # ! -> * -> *
src/Language/PureScript/Declarations.hs+2−1
@@ -33,11 +33,12 @@ type Precedence = Integer
3333-- |
3434-- Associativity for infix operators
3535--
36−data Associativity = Infixl | Infixr deriving (D.Data, D.Typeable)
36+data Associativity = Infixl | Infixr | Infix deriving (D.Data, D.Typeable)
3737
3838instance Show Associativity where
3939 show Infixl = "infixl"
4040 show Infixr = "infixr"
41+ show Infix = "infix"
4142
4243-- |
4344-- Fixity data for infix operators
src/Language/PureScript/Parser/Common.hs+1
@@ -36,6 +36,7 @@ reservedPsNames = [ "data"
3636 , "import"
3737 , "infixl"
3838 , "infixr"
39+ , "infix"
3940 , "class"
4041 , "instance"
4142 , "module"
src/Language/PureScript/Parser/Declarations.hs+7−1
@@ -32,6 +32,11 @@ import Language.PureScript.Parser.Kinds
3232import Language.PureScript.CodeGen.JS.AST
3333import Language.PureScript.Environment
3434
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+
3540parseDataDeclaration :: P.Parsec String ParseState Declaration
3641parseDataDeclaration = do
3742 reserved "data"
@@ -83,7 +88,8 @@ parseExternDeclaration = P.try (reserved "foreign") *> indented *> reserved "imp
8388parseAssociativity :: P.Parsec String ParseState Associativity
8489parseAssociativity =
8590 (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)
8793
8894parseFixity :: P.Parsec String ParseState Fixity
8995parseFixity = Fixity <$> parseAssociativity <*> (indented *> natural)
src/Language/PureScript/Sugar/Operators.hs+1
@@ -107,6 +107,7 @@ matchOperators ops = parseChains
107107toAssoc :: Associativity -> P.Assoc
108108toAssoc Infixl = P.AssocLeft
109109toAssoc Infixr = P.AssocRight
110+toAssoc Infix = P.AssocNone
110111
111112token :: (P.Stream s Identity t, Show t) => (t -> Maybe a) -> P.Parsec s u a
112113token = P.token show (const (P.initialPos ""))