Skip to content

Commit

Permalink
fix imports
Browse files Browse the repository at this point in the history
  • Loading branch information
janmasrovira committed Dec 4, 2024
1 parent 70cbdd0 commit dff0142
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 8 deletions.
6 changes: 5 additions & 1 deletion src/Juvix/Compiler/Concrete/Data/Name.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
module Juvix.Compiler.Concrete.Data.Name where

import Data.List.NonEmpty.Extra qualified as NonEmpty
import Juvix.Data.Fixity
import Juvix.Data.Loc
import Juvix.Data.TopModulePathKey
import Juvix.Data.WithLoc
import Juvix.Extra.Serialize
import Juvix.Prelude
import Juvix.Prelude.Base
import Juvix.Prelude.Pretty as Pretty

type Symbol = WithLoc Text
Expand Down
6 changes: 5 additions & 1 deletion src/Juvix/Data/CodeAnn.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ module Juvix.Data.CodeAnn
where

import Juvix.Compiler.Concrete.Data.Name
import Juvix.Data.Error.GenericError
import Juvix.Data.IsImplicit
import Juvix.Data.Keyword
import Juvix.Data.NameId
import Juvix.Data.NameKind
import Juvix.Data.WithLoc
import Juvix.Extra.Strings qualified as Str
import Juvix.Prelude
import Juvix.Prelude.Base
import Juvix.Prelude.Pretty hiding (braces, brackets, group, list, parens)
import Prettyprinter.Render.Terminal (Color (..), bold, colorDull)

Expand Down
24 changes: 20 additions & 4 deletions src/Juvix/Data/Comment.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module Juvix.Data.Comment where

import Data.HashMap.Strict qualified as HashMap
import Data.Text qualified as Text
import Juvix.Data.CodeAnn (CodeAnn (..), PrettyCodeAnn, ppCodeAnn)
import Juvix.Data.Loc
import Juvix.Extra.Strings qualified as Str
import Juvix.Prelude.Base
Expand Down Expand Up @@ -99,14 +101,28 @@ instance HasLoc SpaceSection where
instance HasLoc Comment where
getLoc = (^. commentInterval)

instance PrettyCodeAnn Comment where
ppCodeAnn = annotate AnnComment . pretty

instance Pretty Comment where
pretty :: Comment -> Doc ann
pretty c = delim (pretty (c ^. commentText))
pretty c = delim (c ^. commentText)
where
delim :: Doc ann -> Doc ann
delim :: Text -> Doc ann
delim = case c ^. commentType of
CommentOneLine -> (Str.commentLineStart <>)
CommentBlock -> enclose Str.commentBlockStart Str.commentBlockEnd
CommentOneLine -> (Str.commentLineStart <>) . pretty
CommentBlock ->
enclose Str.commentBlockStart Str.commentBlockEnd
. pretty
. trimPrefixSpace

trimPrefixSpace :: Text -> Text
trimPrefixSpace =
fromJust
. Text.stripSuffix "\n"
. Text.unlines
. map Text.strip
. Text.lines

allComments :: Comments -> [Comment]
allComments c =
Expand Down
2 changes: 1 addition & 1 deletion src/Juvix/Data/Effect/ExactPrint/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ printSpaceSpan = mapM_ printSpaceSection . (^. spaceSpan)

printComment :: (Members '[State Builder] r) => Comment -> Sem r ()
printComment c = do
append' (annotate AnnComment (P.pretty c))
append' (ppCodeAnn c)
hardline'

popQueue :: (Members '[State Builder] r) => Sem r ()
Expand Down
2 changes: 1 addition & 1 deletion src/Juvix/Data/NameKind.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Juvix.Data.NameKind where

import Juvix.Extra.Serialize
import Juvix.Prelude
import Juvix.Prelude.Base
import Juvix.Prelude.Pretty
import Prettyprinter.Render.Terminal

Expand Down

0 comments on commit dff0142

Please sign in to comment.