Remove redundant keywords from compiler
Background: #18424
This MR removes redundant do
, return
, where
, etc keywords from the compiler/
code-base.
I felt that this codebase is slightly tricky (due to several factors, ranging from its age to the inherent complexity of a compiler), but I nonetheless took the liberty to fix some other stuff
- Formatting discrepancies: Odd numbers of indentation spaces, like 1 or 7 (??). Some conflicting styles (4 versus 2 indents) in neighbouring code blocks have been harmonised. Some dubious spacing situations are also fixed.
- Monadic code that can be simplified:
-= initCts dflags env' $ do
- mapAccumLM (\ccs rhs -> do
- (rhs', ccs') <-
- coreToTopStgRhs dflags ccs this_mod rhs
- return (ccs', rhs'))
- ccs
- pairs
+= initCts dflags env' $
+ mapAccumLM (\ccs rhs -> swap <$> coreToTopStgRhs dflags ccs this_mod rhs
+ ccs
+ pairs
or
- _ -> do { a <- get bh; return (IfUnpackCo a) }
+ _ -> IfUnpackCo <$> get bh
Moreover, some diffs will appear very large. This is often due to a harmonisation of the indent style because:
- Of a 1-space indented function body between two functions that use 2 or 4;
- A
do
keyword that was placed on the same line as the rest of the body.
So yes, they will be ugly.
Other than what was described above, no feature change.
Edited by Hécate Kleidukos