ligo/tools/lsp/squirrel/src/HasComments.hs

23 lines
423 B
Haskell
Raw Normal View History

2020-06-01 18:17:33 +04:00
module HasComments where
import qualified Data.Text as Text
import Pretty
class HasComments c where
getComments :: c -> [Text.Text]
c :: HasComments i => i -> Doc -> Doc
c i d =
case getComments i of
[] -> d
cc -> block (map removeSlashN cc) $$ d
where
removeSlashN txt =
if "\n" `Text.isSuffixOf` txt
then Text.init txt
else txt
instance HasComments () where
getComments () = []