Skip to content

Commit

Permalink
Merge pull request paul-rouse#30 from k-bx/master
Browse files Browse the repository at this point in the history
Add a Semigroup instance
  • Loading branch information
paul-rouse authored Feb 24, 2018
2 parents bee7a79 + 96d66a0 commit 54b93fb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ matrix:
compiler: ": # lts-6"
- env: ARGS="--resolver lts-7"
compiler: ": # lts-7"
- env: ARGS="--resolver lts-10"
compiler: ": # lts-10"
- env: ARGS="--resolver nightly"
compiler: ": # nightly"
- env: ARGS="--resolver lts"
Expand Down
7 changes: 6 additions & 1 deletion Database/MySQL/Base/Types.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import Data.ByteString.Internal (create, memcpy)
import Data.List (intercalate)
import Data.Maybe (catMaybes)
import Data.Monoid (Monoid(..))
import Data.Semigroup (Semigroup(..))
import Data.Typeable (Typeable)
import Data.Word (Word, Word8)
import Foreign.C.Types (CChar, CInt, CUInt, CULong)
Expand Down Expand Up @@ -171,10 +172,14 @@ instance Show FieldFlags where

type FieldFlag = FieldFlags

instance Semigroup FieldFlags where
(<>) (FieldFlags a) (FieldFlags b) = FieldFlags (a .|. b)
{-# INLINE (<>) #-}

instance Monoid FieldFlags where
mempty = FieldFlags 0
{-# INLINE mempty #-}
mappend (FieldFlags a) (FieldFlags b) = FieldFlags (a .|. b)
mappend = (<>)
{-# INLINE mappend #-}

flagNotNull, flagPrimaryKey, flagUniqueKey, flagMultipleKey :: FieldFlag
Expand Down
3 changes: 3 additions & 0 deletions mysql.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ library
base < 5,
bytestring >= 0.9 && < 1.0,
containers
if !impl(ghc >= 8.0)
build-depends:
semigroups >= 0.11 && < 0.19

ghc-options: -Wall
if impl(ghc >= 6.8)
Expand Down

0 comments on commit 54b93fb

Please sign in to comment.