Skip to content

Commit 9db58da

Browse files
committed
fixup! Portage.EBuild: Switch to LinesBuilder
1 parent c5f0551 commit 9db58da

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
@@ -259,9 +263,18 @@ fromDoc = fromDocs . (:[])
259263
fromDocs :: Foldable t => t (Doc ann) -> LinesBuilder ann ()
260264
fromDocs = LinesBuilder . tell . Endo . (\x -> (toList x ++))
261265

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

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

0 commit comments

Comments
 (0)