remove semigroup monoid and replace with nixstring methods
This commit is contained in:
parent
ae6725871b
commit
cfa4824fb3
|
@ -320,7 +320,7 @@ assembleString = \case
|
|||
Indented _ parts -> fromParts parts
|
||||
DoubleQuoted parts -> fromParts parts
|
||||
where
|
||||
fromParts = fmap (fmap mconcat . sequence) . traverse go
|
||||
fromParts = fmap (fmap hackyStringMConcat . sequence) . traverse go
|
||||
|
||||
go = runAntiquoted "\n" (pure . Just . hackyMakeNixStringWithoutContext) (>>= fromValueMay)
|
||||
|
||||
|
|
|
@ -336,7 +336,7 @@ execBinaryOp scope span op lval rarg = do
|
|||
_ -> nverr $ ErrorCall $ unsupportedTypes lval rval
|
||||
|
||||
(NVStr ls, NVStr rs) -> case op of
|
||||
NPlus -> pure $ bin nvStrP (ls `mappend` rs)
|
||||
NPlus -> pure $ bin nvStrP (ls `hackyStringMappend` rs)
|
||||
NEq -> toBool =<< valueEq lval rval
|
||||
NNEq -> toBool . not =<< valueEq lval rval
|
||||
NLt -> toBool $ ls < rs
|
||||
|
|
|
@ -6,6 +6,8 @@ module Nix.NixString (
|
|||
, hackyStringIgnoreContext
|
||||
, hackyMakeNixStringWithoutContext
|
||||
, hackyModifyNixContents
|
||||
, hackyStringMappend
|
||||
, hackyStringMConcat
|
||||
) where
|
||||
|
||||
import qualified Data.HashSet as S
|
||||
|
@ -14,7 +16,7 @@ import Data.Text (Text)
|
|||
import GHC.Generics
|
||||
import Data.Semigroup
|
||||
|
||||
{-# WARNING hackyStringIgnoreContextMaybe, hackyStringIgnoreContext, hackyMakeNixStringWithoutContext, hackyModifyNixContents "This NixString function needs to be replaced" #-}
|
||||
{-# WARNING hackyStringMappend, hackyStringMConcat, hackyStringIgnoreContextMaybe, hackyStringIgnoreContext, hackyMakeNixStringWithoutContext, hackyModifyNixContents "This NixString function needs to be replaced" #-}
|
||||
|
||||
-- | A 'ContextFlavor' describes the sum of possible derivations for string contexts
|
||||
data ContextFlavor =
|
||||
|
@ -39,12 +41,20 @@ data NixString = NixString
|
|||
|
||||
instance Hashable NixString
|
||||
|
||||
instance Semigroup NixString where
|
||||
NixString s1 t1 <> NixString s2 t2 = NixString (s1 <> s2) (t1 <> t2)
|
||||
-- | Combine two NixStrings using mappend
|
||||
hackyStringMappend :: NixString -> NixString -> NixString
|
||||
hackyStringMappend (NixString s1 t1) (NixString s2 t2) = NixString (s1 <> s2) (t1 <> t2)
|
||||
|
||||
instance Monoid NixString where
|
||||
mempty = NixString mempty mempty
|
||||
mappend = (<>)
|
||||
-- | Combine NixStrings using mconcat
|
||||
hackyStringMConcat :: [NixString] -> NixString
|
||||
hackyStringMConcat = foldr hackyStringMappend (NixString mempty mempty)
|
||||
|
||||
--instance Semigroup NixString where
|
||||
--NixString s1 t1 <> NixString s2 t2 = NixString (s1 <> s2) (t1 <> t2)
|
||||
|
||||
--instance Monoid NixString where
|
||||
-- mempty = NixString mempty mempty
|
||||
-- mappend = (<>)
|
||||
|
||||
-- | Extract the string contents from a NixString that has no context
|
||||
hackyStringIgnoreContextMaybe :: NixString -> Maybe Text
|
||||
|
|
Loading…
Reference in a new issue