File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff 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+
1317module Portage.EBuild
1418 ( EBuild (.. )
1519 , ebuildTemplate
@@ -259,9 +263,18 @@ fromDoc = fromDocs . (:[])
259263fromDocs :: Foldable t => t (Doc ann ) -> LinesBuilder ann ()
260264fromDocs = 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
262273newtype 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
265278instance (a ~ () ) => IsString (LinesBuilder ann a ) where
266279 fromString = fromDoc . fromString
267280
You can’t perform that action at this time.
0 commit comments