Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow stan hint, explicit fixity (default is infixl 9). #619

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .stan.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,6 @@
scope = "all"
type = "Exclude"

# Missing fixity declaration for operator
[[check]]
id = "STAN-0301"
scope = "all"
type = "Exclude"

# Using tuples of big size (>= 4) can decrease code readability
[[check]]
id = "STAN-0302"
Expand Down
3 changes: 3 additions & 0 deletions src/Language/Fixpoint/Misc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -425,12 +425,15 @@ allCombinations xs = assert (all ((length xs == ) . length)) $ go xs
powerset :: [a] -> [[a]]
powerset xs = filterM (const [False, True]) xs

infixl 9 =>>
(=>>) :: Monad m => m b -> (b -> m a) -> m b
(=>>) m f = m >>= (\x -> f x >> return x)

infixl 9 <<=
(<<=) :: Monad m => (b -> m a) -> m b -> m b
(<<=) = flip (=>>)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would think these should be removed from here. And replaced in the code with >>= and =<<.

Copy link
Contributor Author

@philderbeast philderbeast Aug 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like (=>>) :: Monad m => m b -> (b -> m a) -> m b and (<<=) are not used.

Copy link
Contributor Author

@philderbeast philderbeast Aug 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a quick peek at liquidhaskell. Each operator is only used once there, (=>>) in Language.Haskell.Liquid.Constraint.Fresh and (<<=) in Language.Haskell.Liquid.Constraint.Generate. Perhaps those modules should define such an operator privately or use the inline equivalent and we remove them from liquid-fixpoint?


infixl 9 <$$>
(<$$>) :: (Monad m) => (a -> m b) -> [a] -> m [b]
_ <$$> [] = return []
f <$$> [x1] = singleton <$> f x1
philderbeast marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
2 changes: 2 additions & 0 deletions src/Language/Fixpoint/Solver/Instantiate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ eval γ stk = go
go (POr es) = POr <$> (go <$$> es)
go e = return e

infixl 9 <$$>
(<$$>) :: (Monad m) => (a -> m b) -> [a] -> m [b]
f <$$> xs = f Misc.<$$> xs

Expand Down Expand Up @@ -805,6 +806,7 @@ withCtx cfg file env k = do
_ <- SMT.cleanupContext ctx
return res

infixl 9 ~>
(~>) :: (Expr, String) -> Expr -> EvalST Expr
(e, _str) ~> e' = do
let msg = "PLE: " ++ _str ++ showpp (e, e')
Expand Down
2 changes: 2 additions & 0 deletions src/Language/Fixpoint/Solver/PLE.hs
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ feVal (FE f) = f
feAny :: [FinalExpand] -> FinalExpand
feAny xs = FE $ any feVal xs

infixl 9 <|>
(<|>) :: FinalExpand -> FinalExpand -> FinalExpand
(<|>) (FE True) _ = expand
(<|>) _ f = f
Expand Down Expand Up @@ -776,6 +777,7 @@ evalRESTWithCache cacheRef γ ctx acc rp =
addConst (e,e') = if isConstant (knDCs γ) e'
then ctx { icSimpl = M.insert e e' $ icSimpl ctx} else ctx

infixl 9 <$$>
(<$$>) :: (Monad m) => (a -> m b) -> [a] -> m [b]
f <$$> xs = f Misc.<$$> xs

Expand Down
1 change: 1 addition & 0 deletions src/Language/Fixpoint/Solver/Sanitize.hs
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ dropFuncSortedShadowedBinders fi = dropBinders ok (const True) fi
ok x t = M.member x defs ==> (F.allowHO fi || isFirstOrder t)
defs = M.fromList $ F.toListSEnv $ F.gLits fi

infixl 9 ==>
(==>) :: Bool -> Bool -> Bool
p ==> q = not p || q

Expand Down
1 change: 1 addition & 0 deletions src/Language/Fixpoint/Types/Constraints.hs
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,7 @@ toFixpoint cfg x' = cfgDoc cfg
| mdata = vcat . map metaDoc . M.toList . bindInfo
| otherwise = \_ -> text "\n"

infixl 9 $++$
($++$) :: Doc -> Doc -> Doc
x $++$ y = x $+$ text "\n" $+$ y

Expand Down
2 changes: 2 additions & 0 deletions src/Language/Fixpoint/Types/Refinements.hs
Original file line number Diff line number Diff line change
Expand Up @@ -892,9 +892,11 @@ pAndNoDedup = simplifyExpr id . PAnd

pOr = simplify . POr

infixl 9 &.&
(&.&) :: Pred -> Pred -> Pred
(&.&) p q = pAnd [p, q]

infixl 9 |.|
(|.|) :: Pred -> Pred -> Pred
(|.|) p q = pOr [p, q]

Expand Down
1 change: 1 addition & 0 deletions src/Language/Fixpoint/Types/Visitor.hs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ accum !z = modify (mappend z)
-- !cur <- get
-- put ((mappend $!! z) $!! cur)

infixl 9 <$$>
(<$$>) :: (Monad m) => (a -> m b) -> [a] -> m [b]
f <$$> xs = f Misc.<$$> xs

Expand Down
1 change: 1 addition & 0 deletions src/Language/Fixpoint/Utils/Builder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ fromText = Leaf . B.fromText
parens :: Builder -> Builder
parens b = "(" <> b <> ")"

infixl 9 <+>
(<+>) :: Builder -> Builder -> Builder
x <+> y = x <> " " <> y

Expand Down