Commit dca4b28b authored by Oleg Grenrus's avatar Oleg Grenrus
Browse files

Add Distribution.Compat.DList

parent 81768070
......@@ -494,6 +494,7 @@ library
Distribution.Compat.CopyFile
Distribution.Compat.GetShortPathName
Distribution.Compat.MonadFail
Distribution.Compat.DList
Distribution.Compat.Prelude
Distribution.GetOpt
Distribution.Lex
......
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Compat.DList
-- Copyright : (c) Ben Gamari 2015-2019
-- License : BSD3
--
-- Maintainer : cabal-dev@haskell.org
-- Stability : experimental
-- Portability : portable
--
-- A very simple difference list.
module Distribution.Compat.DList (
DList,
runDList,
singleton,
) where
import Prelude ()
import Distribution.Compat.Prelude
-- | Difference list.
newtype DList a = DList ([a] -> [a])
runDList :: DList a -> [a]
runDList (DList run) = run []
-- | Make 'DList' with containing single element.
singleton :: a -> DList a
singleton a = DList (a:)
instance Monoid (DList a) where
mempty = DList id
mappend = (<>)
instance Semigroup (DList a) where
DList a <> DList b = DList (a . b)
......@@ -14,21 +14,7 @@ module Distribution.Lex (
import Prelude ()
import Distribution.Compat.Prelude
newtype DList a = DList ([a] -> [a])
runDList :: DList a -> [a]
runDList (DList run) = run []
singleton :: a -> DList a
singleton a = DList (a:)
instance Monoid (DList a) where
mempty = DList id
mappend = (<>)
instance Semigroup (DList a) where
DList a <> DList b = DList (a . b)
import Distribution.Compat.DList
tokenizeQuotedWords :: String -> [String]
tokenizeQuotedWords = filter (not . null) . go False mempty
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment