ivory-backend-c 0.1.0.7 → 0.1.0.8
raw patch · 3 files changed
+20/−9 lines, 3 filesdep +semigroupsnew-uploader
Dependencies added: semigroups
Files
- ivory-backend-c.cabal +4/−1
- src/Ivory/Compile/C/CmdlineFrontend/Options.hs +6/−2
- src/Ivory/Compile/C/Types.hs +10/−6
ivory-backend-c.cabal view
@@ -2,7 +2,7 @@ -- see http://haskell.org/cabal/users-guide/ name: ivory-backend-c-version: 0.1.0.7+version: 0.1.0.8 author: Galois, Inc. maintainer: leepike@galois.com category: Language@@ -47,6 +47,9 @@ ivory, ivory-opts, ivory-artifact+ if impl(ghc < 8)+ build-depends: semigroups+ hs-source-dirs: src default-language: Haskell2010
src/Ivory/Compile/C/CmdlineFrontend/Options.hs view
@@ -2,6 +2,7 @@ import Prelude () import Prelude.Compat+import Data.Semigroup (Semigroup(..)) import System.Console.GetOpt (ArgDescr (..), ArgOrder (Permute), OptDescr (..), getOpt, usageInfo)@@ -13,10 +14,13 @@ data OptParser opt = OptParser [String] (opt -> opt) +instance Semigroup (OptParser opt) where+ -- left-to-right composition makes the last option parsed take precedence+ OptParser as f <> OptParser bs g = OptParser (as ++ bs) (f . g)+ instance Monoid (OptParser opt) where mempty = OptParser [] id- -- left-to-right composition makes the last option parsed take precedence- OptParser as f `mappend` OptParser bs g = OptParser (as ++ bs) (f . g)+ mappend = (<>) -- | Option parser succeeded, use this function to transform the default -- options.
src/Ivory/Compile/C/Types.hs view
@@ -8,6 +8,7 @@ import Prelude.Compat import Data.List (nub)+import Data.Semigroup (Semigroup(..)) import Language.C.Quote.GCC import qualified "language-c-quote" Language.C.Syntax as C@@ -35,14 +36,17 @@ , headers :: (Includes, Sources) } deriving Show -instance Monoid CompileUnits where- mempty = CompileUnits mempty mempty mempty- (CompileUnits n0 s0 h0) `mappend` (CompileUnits n1 s1 h1) =- CompileUnits (n0 `mappend` n1)- (go (s0 `mappend` s1))- (go (h0 `mappend` h1))+instance Semigroup CompileUnits where+ CompileUnits n0 s0 h0 <> CompileUnits n1 s1 h1 =+ CompileUnits (n0 <> n1)+ (go (s0 <> s1))+ (go (h0 <> h1)) where go (i,s) = (nub i, nub s)++instance Monoid CompileUnits where+ mempty = CompileUnits mempty mempty mempty+ mappend = (<>) --------------------------------------------------------------------------------