Skip to content

Commit

Permalink
new line after comment
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-bodavskiy committed Nov 19, 2024
1 parent fb5bddf commit f32e6c4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/namma-dsl/src/NammaDSL/Generator/Haskell/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,14 @@ mkFullUserActionType apiRead apiTT = do
delimiterComment :: String -> Writer r CodeUnit
delimiterComment handlerName = do
let delimiterLength = 80
commentW $ " " <> replicate (delimiterLength - 3) '='
commentW $ " " <> replicate (delimiterLength - 4) '='
commentW $
replicate 11 '-'
<> " "
<> handlerName
<> do
let remainder = delimiterLength - length handlerName - 15
let remainder = delimiterLength - length handlerName - 16
if remainder > 0
then " " <> replicate remainder '-'
else ""
addNewLineW
1 change: 1 addition & 0 deletions lib/namma-dsl/src/NammaDSL/Lib/Interpreter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ interpretSplice (Splice e) = "$(" <> pprint' e <> ")" <> "\n\n"

interpretComment :: Comment -> String
interpretComment (Comment str) = "--" <> str <> "\n"
interpretComment AddNewLine = "\n"

myStyle :: Pretty.Style
myStyle = Pretty.style {Pretty.lineLength = 300}
Expand Down
3 changes: 3 additions & 0 deletions lib/namma-dsl/src/NammaDSL/Lib/TH.hs
Original file line number Diff line number Diff line change
Expand Up @@ -428,3 +428,6 @@ matchWOD patQ bodyQ = do

commentW :: String -> Writer r CodeUnit
commentW str = tell [CodeComment (Comment str)]

addNewLineW :: Writer r CodeUnit
addNewLineW = tell [CodeComment AddNewLine]
3 changes: 2 additions & 1 deletion lib/namma-dsl/src/NammaDSL/Lib/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ data CodeUnit = CodeDec [TH.Dec] | CodeSplice Splice | CodeComment Comment

newtype Splice = Splice TH.Exp deriving (Eq)

newtype Comment = Comment String
-- sometimes extra new line required after comment
data Comment = Comment String | AddNewLine

type Writer r w = WriterT [w] (Q r) ()

Expand Down

0 comments on commit f32e6c4

Please sign in to comment.