Skip to content

Commit bcf12ee

Browse files
committed
fixup! Portage.EBuild: Switch to LinesBuilder
1 parent a2c07b6 commit bcf12ee

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Portage/EBuild.hs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ as understood by the Portage package manager.
99
{-# LANGUAGE CPP #-}
1010
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
1111
{-# LANGUAGE OverloadedStrings #-}
12-
{-# LANGUAGE TypeFamilies #-} -- Needed to get OverloadedStrings to work
12+
13+
-- Needed to get OverloadedStrings to work
14+
{-# LANGUAGE TypeFamilies #-}
15+
{-# LANGUAGE TypeOperators #-}
16+
1317
module Portage.EBuild
1418
( EBuild(..)
1519
, ebuildTemplate
@@ -260,9 +264,18 @@ fromDoc = fromDocs . (:[])
260264
fromDocs :: Foldable t => t (Doc ann) -> LinesBuilder ann ()
261265
fromDocs = LinesBuilder . tell . Endo . (\x -> (toList x ++))
262266

267+
-- | Builds up a list of @prettyprinter@ 'Doc's and then concats them with
268+
-- 'vcat'. It is helpful for when a logical piece of the ebuild may use a
269+
-- variable number of lines, including no lines at all.
270+
--
271+
-- Since it is a 'Monad', it can be used in a @do@ block.
272+
--
273+
-- Uses 'Endo' internally for more efficient list concats
263274
newtype LinesBuilder ann a = LinesBuilder (Writer (Endo [Doc ann]) a)
264275
deriving (Functor, Applicative, Monad)
265276

277+
-- TypeFamilies/TypeOperators needs to be used here otherwise we get errors
278+
-- when we go try to use OverloadedStrings
266279
instance (a ~ ()) => IsString (LinesBuilder ann a) where
267280
fromString = fromDoc . fromString
268281

0 commit comments

Comments
 (0)