Skip to content

Commit

Permalink
Add some code documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
piegamesde committed May 5, 2023
1 parent 28a54b3 commit 7fe6a99
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Nixfmt/Predoc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,22 @@ import Data.Text as Text (Text, concat, length, pack, replicate)
-- This means that e.g. a Space followed by an Emptyline results in just an
-- Emptyline.
data Spacing
= Softbreak
=
-- | Line break or nothing (soft)
Softbreak
-- | Line break or nothing
| Break
-- | Always a space
| Hardspace
-- | Line break or space (soft)
| Softspace
-- | Line break or space
| Space
-- | Always a line break
| Hardline
-- | Two line breaks
| Emptyline
-- | n line breaks
| Newlines Int
deriving (Show, Eq, Ord)

Expand Down Expand Up @@ -105,24 +114,31 @@ nest level = pure . Node (Nest level)
base :: Doc -> Doc
base = pure . Node Base

-- | Line break or nothing (soft)
softline' :: Doc
softline' = [Spacing Softbreak]

-- | Line break or nothing
line' :: Doc
line' = [Spacing Break]

-- | Line break or space (soft)
softline :: Doc
softline = [Spacing Softspace]

-- | Line break or space
line :: Doc
line = [Spacing Space]

-- | Always space
hardspace :: Doc
hardspace = [Spacing Hardspace]

-- | Always line break
hardline :: Doc
hardline = [Spacing Hardline]

-- | Two line breaks
emptyline :: Doc
emptyline = [Spacing Emptyline]

Expand Down

0 comments on commit 7fe6a99

Please sign in to comment.