Commit 2eb501f3 authored by Camil Staps's avatar Camil Staps 🐧

Add parentheses to instances with infix operators

parent 38ba9205
Pipeline #39869 failed with stage
in 1 minute and 39 seconds
......@@ -240,14 +240,14 @@ where
instance < Position
where
< a b = index a < index b
(<) a b = index a < index b
where
index (FunPos f l n) = (f, l, n)
index (LinePos f l) = (f, l, "")
index (PreDefPos id) = ("", -1, id.id_name)
index NoPos = ("", -2, "")
instance < CommentIndex where < (CI a b c) (CI d e f) = (a,b,c) < (d,e,f)
instance < CommentIndex where (<) (CI a b c) (CI d e f) = (a,b,c) < (d,e,f)
putCC k v coll :== case commentIndex k of
Nothing -> coll
......
......@@ -16,7 +16,7 @@ import Data.Maybe
instance == Type
where
== a b = case a of
(==) a b = case a of
Type t args -> case b of
Type t` args` -> t==t` && args==args`
_ -> False
......@@ -44,7 +44,7 @@ where
instance == TypeRestriction
where
== a b = case a of
(==) a b = case a of
Instance cls ts -> case b of
Instance cls` ts` -> cls==cls` && ts==ts`
_ -> False
......@@ -54,7 +54,7 @@ where
instance == Kind
where
== a b = case a of
(==) a b = case a of
KStar -> b=:KStar
KArrow a b -> case b of
KArrow a` b` -> a==a` && b==b`
......@@ -62,7 +62,7 @@ where
instance == TypeContext
where
== (TypeContext a) (TypeContext b) = a == b
(==) (TypeContext a) (TypeContext b) = a == b
childTypes :: !Type -> [Type]
childTypes t = case t of
......
......@@ -49,29 +49,29 @@ from Text.Parsers.Simple.Core import :: Parser, :: Error,
instance == Token
where
== (TIdent a) b = case b of
(==) (TIdent a) b = case b of
TIdent b -> a == b
_ -> False
== (TVar a) b = case b of
(==) (TVar a) b = case b of
TVar b -> a == b
_ -> False
== TArrow b = b=:TArrow
== TComma b = b=:TComma
== TStar b = b=:TStar
== TAnonymous b = b=:TAnonymous
== TUnboxed b = b=:TUnboxed
== TStrict b = b=:TStrict
== TColon b = b=:TColon
== TUniversalQuantifier b = b=:TUniversalQuantifier
== TPipe b = b=:TPipe
== TAmpersand b = b=:TAmpersand
== TLtEq b = b=:TLtEq
== TParenOpen b = b=:TParenOpen
== TParenClose b = b=:TParenClose
== TBrackOpen b = b=:TBrackOpen
== TBrackClose b = b=:TBrackClose
== TBraceOpen b = b=:TBraceOpen
== TBraceClose b = b=:TBraceClose
(==) TArrow b = b=:TArrow
(==) TComma b = b=:TComma
(==) TStar b = b=:TStar
(==) TAnonymous b = b=:TAnonymous
(==) TUnboxed b = b=:TUnboxed
(==) TStrict b = b=:TStrict
(==) TColon b = b=:TColon
(==) TUniversalQuantifier b = b=:TUniversalQuantifier
(==) TPipe b = b=:TPipe
(==) TAmpersand b = b=:TAmpersand
(==) TLtEq b = b=:TLtEq
(==) TParenOpen b = b=:TParenOpen
(==) TParenClose b = b=:TParenClose
(==) TBrackOpen b = b=:TBrackOpen
(==) TBrackClose b = b=:TBrackClose
(==) TBraceOpen b = b=:TBraceOpen
(==) TBraceClose b = b=:TBraceClose
isTIdent t = t=:(TIdent _)
isTVar t = t=:(TVar _)
......
......@@ -20,9 +20,9 @@ import Text.GenJSON
instance zero (TypeTree v) where zero = Node (Var "ra") [] []
instance < (TypeTree v) where < (Node a _ _) (Node b _ _) = a < b
instance < (TypeTree v) where (<) (Node a _ _) (Node b _ _) = a < b
derive gLexOrd Type, Maybe, TypeRestriction, TypeContext
instance < Type where < t u = (t =?= u) =: LT
instance < Type where (<) t u = (t =?= u) =: LT
derive JSONEncode TypeTree, Type, TypeRestriction, TypeContext
derive JSONDecode TypeTree, Type, TypeRestriction, TypeContext
......
......@@ -17,7 +17,7 @@ where
instance <*> (ReaderT r m) | Monad m
where
<*> mf mx = ap mf mx
(<*>) mf mx = ap mf mx
instance Monad (ReaderT r m) | Monad m where
bind m k = ReaderT (\r -> runReaderT m r >>= \a -> runReaderT (k a) r)
......
......@@ -25,11 +25,11 @@ where
instance *> (StateT s m) | Monad m
where
*> fa fb = liftA2 (\a b -> b) fa fb
(*>) fa fb = liftA2 (\a b -> b) fa fb
instance <* (StateT s m) | Monad m
where
<* fa fb = liftA2 (\a b -> a) fa fb
(<*) fa fb = liftA2 (\a b -> a) fa fb
instance Alternative (StateT s m) | Alternative m where
empty = StateT (const empty)
......
......@@ -19,7 +19,7 @@ where
instance <*> (WriterT w m) | Monad m & Monoid w
where
<*> mf mx = ap mf mx
(<*>) mf mx = ap mf mx
instance Monad (WriterT w m) | Monad m & Monoid w where
bind m k = WriterT (runWriterT m >>= \(a, w) ->
......
......@@ -13,9 +13,9 @@ import Data.Bifunctor
import Data.GenEq
instance == (Either a b) | == a & == b where
== (Left x) (Left y) = x == y
== (Right x) (Right y) = x == y
== _ _ = False
(==) (Left x) (Left y) = x == y
(==) (Right x) (Right y) = x == y
(==) _ _ = False
instance Functor (Either a) where
fmap f (Left l) = Left l
......
......@@ -4,7 +4,7 @@ import StdEnv
import Data.Either
instance < (Either a b) | < a & < b where
< (Left x) (Left y) = x < y
< (Right x) (Right y) = x < y
< (Left _) (Right _) = True
< (Right _) (Left _) = False
(<) (Left x) (Left y) = x < y
(<) (Right x) (Right y) = x < y
(<) (Left _) (Right _) = True
(<) (Right _) (Left _) = False
......@@ -25,10 +25,10 @@ instance Monad (MaybeError e) where
bind (Ok r) k = k r
instance == (MaybeError a b) | == a & == b where
== (Ok x) y = case y of
(==) (Ok x) y = case y of
Ok y = x == y
_ = False
== (Error x) y = case y of
(==) (Error x) y = case y of
Error y = x == y
_ = False
......
......@@ -17,11 +17,11 @@ instance zero Diff where zero = {status=Common, value="", children=[]}
instance == DiffStatus
where
== Common Common = True
== Changed Changed = True
== OnlyRight OnlyRight = True
== OnlyLeft OnlyLeft = True
== _ _ = False
(==) Common Common = True
(==) Changed Changed = True
(==) OnlyRight OnlyRight = True
(==) OnlyLeft OnlyLeft = True
(==) _ _ = False
setStatus :: !DiffStatus !Diff -> Diff
setStatus s d = {d & status=s, children=map (setStatus s) d.children}
......
......@@ -23,16 +23,16 @@ unLPath (LP xs) = xs
//instance toString (LPath a) | toString a where
//toString (LP xs) = foldr (\x xs -> toString x +++ " " +++ xs) "" xs
instance == (LPath a) | == a where
== (LP []) (LP []) = True
== (LP [(_,x):_]) (LP [(_,y):_]) = x==y
== (LP _) (LP _) = False
instance == (LPath a) | == a
where
(==) (LP []) (LP []) = True
(==) (LP [(_,x):_]) (LP [(_,y):_]) = x==y
(==) (LP _) (LP _) = False
instance < (LPath a) | gLexOrd{|*|} a where
< (LP [(_,x):_]) (LP [(_,y):_]) = case x =?= y of
LT -> True
_ -> False
< _ _ = False
instance < (LPath a) | gLexOrd{|*|} a
where
(<) (LP [(_,x):_]) (LP [(_,y):_]) = (x =?= y)=:LT
(<) _ _ = False
// | Decompose a graph into the 'Context' for an arbitrarily-chosen 'Node'
// and the remaining 'Graph'.
......@@ -391,9 +391,8 @@ hasNeighborAdj gr v a = 'Data.List'.elem a (lneighbors gr v)
:: GroupEdges b = GEs (LEdge [b])
instance == (GroupEdges b) | Eq b where
== (GEs (v1,w1,bs1)) (GEs (v2,w2,bs2)) = v1 == v2
&& w1 == w2
&& eqLists bs1 bs2
(==) (GEs (v1,w1,bs1)) (GEs (v2,w2,bs2)) =
v1 == v2 && w1 == w2 && eqLists bs1 bs2
eqLists :: [a] [a] -> Bool | Eq a
eqLists xs ys = False // TODO FIXME null (xs \\ ys) && null (ys \\ xs)
......
......@@ -92,11 +92,11 @@ instance Graph Gr where
matchAny g = defMatchAny g
instance DynGraph Gr where
<&> (p, v, l, s) (Gr g)
#! g1 = 'Data.IntMap.Strict'.insert v (fromAdj p, l, fromAdj s) g
#! g2 = addSucc g1 v p
#! g3 = addPred g2 v s
= Gr g3
(<&>) (p, v, l, s) (Gr g)
#! g1 = 'Data.IntMap.Strict'.insert v (fromAdj p, l, fromAdj s) g
#! g2 = addSucc g1 v p
#! g3 = addPred g2 v s
= Gr g3
matchGr :: Node (Gr a b) -> Decomp Gr a b
matchGr node (Gr g)
......
......@@ -47,22 +47,23 @@ instance == (Heap a) where
go _ _ _ = False
(==) _ _ = False
instance < (Heap a) where
< Empty Empty = False
< Empty _ = True
< _ Empty = False
< a=:(Heap _ leq _) b = go leq ('Data.Foldable'.toList a) ('Data.Foldable'.toList b)
where
go f [x:xs] [y:ys] =
if (f x y)
(if (f y x)
(go f xs ys)
True)
False
go f [] [] = False
go f [] [_:_] = True
go f [_:_] [] = False
< _ _ = False
instance < (Heap a)
where
(<) Empty Empty = False
(<) Empty _ = True
(<) _ Empty = False
(<) a=:(Heap _ leq _) b = go leq ('Data.Foldable'.toList a) ('Data.Foldable'.toList b)
where
go f [x:xs] [y:ys] =
if (f x y)
(if (f y x)
(go f xs ys)
True)
False
go f [] [] = False
go f [] [_:_] = True
go f [_:_] [] = False
(<) _ _ = False
// /O(1)/. Is the heap empty?
......
......@@ -132,7 +132,7 @@ instance <*> (MaybeT m) | Monad m where
instance Alternative (MaybeT m) | Monad m where
empty = MaybeT $ return Nothing
<|> x y = MaybeT $
(<|>) x y = MaybeT $
runMaybeT x >>= \v ->
case v of
Nothing -> runMaybeT y
......
......@@ -3,7 +3,7 @@ implementation module Data.Maybe.Ord
import StdEnv, Data.Maybe
instance < (Maybe a) | < a where
< Nothing Nothing = False
< Nothing _ = True
< (Just a1) (Just a2) = a1 < a2
< _ _ = False
(<) Nothing Nothing = False
(<) Nothing _ = True
(<) (Just a1) (Just a2) = a1 < a2
(<) _ _ = False
......@@ -16,8 +16,8 @@ import Text.GenJSON
:: *NativeDB v a :== *{!*Entry v a}
instance == Index where == (Index a) (Index b) = a == b
instance < Index where < (Index a) (Index b) = a < b
instance == Index where (==) (Index a) (Index b) = a == b
instance < Index where (<) (Index a) (Index b) = a < b
newDB :: ![v] -> *NativeDB v a
newDB vs = {{value=hyperstrict v,included=True,annotations=[!!]} \\ v <- vs}
......
......@@ -24,7 +24,7 @@ import StdDebug
derive gEq Angle, BasicImg, BasicImgAttr, ImageTag, ImgTransform, LookupSpan, Span
instance == ImgTransform where == a b = a === b
instance == ImgTransform where (==) a b = a === b
toFontDef` :: !FontDef -> FontDef`
toFontDef` fd
......@@ -676,9 +676,9 @@ ImgEventhandler`ConsName ImgEventhandlerOnMouseMoveAttr` = "ImgEventhandlerOnM
ImgEventhandler`ConsName ImgEventhandlerOnMouseOutAttr` = "ImgEventhandlerOnMouseOutAttr`"
ImgEventhandler`ConsName ImgEventhandlerDraggableAttr` = "ImgEventhandlerDraggableAttr`"
instance < (ImgEventhandler m) where < a b = ImgEventhandlerConsName a < ImgEventhandlerConsName b
instance == (ImgEventhandler m) where == a b = ImgEventhandlerConsName a == ImgEventhandlerConsName b
instance == DefuncImgEventhandler` where == a b = ImgEventhandler`ConsName a == ImgEventhandler`ConsName b
instance < (ImgEventhandler m) where (<) a b = ImgEventhandlerConsName a < ImgEventhandlerConsName b
instance == (ImgEventhandler m) where (==) a b = ImgEventhandlerConsName a == ImgEventhandlerConsName b
instance == DefuncImgEventhandler` where (==) a b = ImgEventhandler`ConsName a == ImgEventhandler`ConsName b
ImgAttrConsName :: !BasicImgAttr -> String
ImgAttrConsName (BasicImgStrokeAttr _) = "BasicImgStrokeAttr"
......@@ -690,8 +690,8 @@ ImgAttrConsName (BasicImgFillOpacityAttr _) = "BasicImgFillOpacityAttr"
ImgAttrConsName (BasicImgFillAttr _) = "BasicImgFillAttr"
ImgAttrConsName (BasicImgDashAttr _) = "BasicImgDashAttr"
instance < BasicImgAttr where < a b = ImgAttrConsName a < ImgAttrConsName b
instance == BasicImgAttr where == a b = ImgAttrConsName a == ImgAttrConsName b
instance < BasicImgAttr where (<) a b = ImgAttrConsName a < ImgAttrConsName b
instance == BasicImgAttr where (==) a b = ImgAttrConsName a == ImgAttrConsName b
tag` :: !ImageTag !(Image` m) !ImgNodePath !FontSpans !TextSpans !ImgTables -> (!Img,!ImgTables)
tag` t=:(ImageTagUser no label) image p font_spans txt_spans imgTables
......
......@@ -57,8 +57,8 @@ getfontvariant fontdef = getfontvariant` fontdef
getfontweight :: !FontDef -> String
getfontweight fontdef = getfontweight` fontdef
instance == FontDef where == fd1 fd2 = fd1 === fd2
instance < FontDef where < fd1 fd2 = fd1.fontfamily` < fd2.fontfamily`
instance == FontDef where (==) fd1 fd2 = fd1 === fd2
instance < FontDef where (<) fd1 fd2 = fd1.fontfamily` < fd2.fontfamily`
|| fd1.fontysize` < fd2.fontysize`
|| fd1.fontstretch` < fd2.fontstretch`
|| fd1.fontstyle` < fd2.fontstyle`
......@@ -67,7 +67,7 @@ instance < FontDef where < fd1 fd2 = fd1.fontfamily` < fd2.fontfamily`
instance toString FontDef where toString font = printToString font
derive gEq LineMarkerPos
instance == LineMarkerPos where == lm1 lm2 = lm1 === lm2
instance == LineMarkerPos where (==) lm1 lm2 = lm1 === lm2
instance toSVGColor String where toSVGColor name = SVGColorText name
instance toSVGColor RGB where toSVGColor {RGB | r, g, b} = SVGRGB r g b
......
......@@ -765,26 +765,26 @@ where
instance == JSONNode
where
// NB: put the most frequently encountered constructors at the top for performance
== (JSONObject xs) y = case y of
(==) (JSONObject xs) y = case y of
JSONObject ys
-> sortBy cmpFst xs == sortBy cmpFst ys
-> False
where
cmpFst = (<) `on` fst
== (JSONArray x) y = case y of JSONArray y -> x==y; _ -> False
== (JSONString x) y = case y of JSONString y -> x==y; _ -> False
== (JSONInt x) y = case y of
(==) (JSONArray x) y = case y of JSONArray y -> x==y; _ -> False
(==) (JSONString x) y = case y of JSONString y -> x==y; _ -> False
(==) (JSONInt x) y = case y of
JSONInt y -> x==y
JSONReal y -> toString (toReal x) == toString y
_ -> False
== (JSONReal x) y = case y of
(==) (JSONReal x) y = case y of
JSONReal y -> x==y
JSONInt y -> toString (toReal y) == toString x
_ -> False
== JSONNull y = y=:JSONNull
== (JSONBool x) y = case y of JSONBool y -> x==y; _ -> False
== (JSONRaw x) y = case y of JSONRaw y -> x==y; _ -> False
== JSONError y = y=:JSONError
(==) JSONNull y = y=:JSONNull
(==) (JSONBool x) y = case y of JSONBool y -> x==y; _ -> False
(==) (JSONRaw x) y = case y of JSONRaw y -> x==y; _ -> False
(==) JSONError y = y=:JSONError
gEq{|JSONNode|} x y = x == y
......
......@@ -83,7 +83,7 @@ instance toString Expr where
toString (ExprPair _ _) = abort "toString on auxiliary ExprPair\n"
instance == Expr where
== x y = x === y
(==) x y = x === y
derive gEq Expr, GenConsAssoc
:: ParseState s =
......
......@@ -5,7 +5,7 @@ import Data.Error, Data.Either, Data.Maybe, Text, Data.GenEq, Data.Func, Data._A
from Text.Parsers.CParsers.ParserCombinators import :: Parser, :: ParsResult, :: CParser, &>, +&+, +&-, -&+, <!>, <&, <&>, <*?>, <@, >?<, @>, begin1, satisfy, symbol, yield, <|>, <+?>, fail
instance == XMLDoc where
== x y = x === y
(==) x y = x === y
uname :: !String -> XMLQName
uname name = XMLQName Nothing name
......
  • @peter88 Just a heads-up: this commit contains changes to your Graphics.Scalable required to make it compile with the latest compiler, so be on the lookout for conflicts.

Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment