sql-words 0.1.5.1 → 0.1.6.0
raw patch · 2 files changed
+29/−13 lines, 2 filesdep +semigroups
Dependencies added: semigroups
Files
- sql-words.cabal +6/−3
- src/Language/SQL/Keyword/Internal/Type.hs +23/−10
sql-words.cabal view
@@ -1,5 +1,5 @@ name: sql-words-version: 0.1.5.1+version: 0.1.6.0 synopsis: SQL keywords data constructors into OverloadedString description: This package contiains SQL keywords constructors defined as OverloadedString literals and helper functions to concate these.@@ -8,11 +8,12 @@ license-file: LICENSE author: Kei Hibino maintainer: ex8k.hibino@gmail.com-copyright: Copyright (c) 2013-2017 Kei Hibino+copyright: Copyright (c) 2013-2018 Kei Hibino category: Database build-type: Simple cabal-version: >=1.10-tested-with: GHC == 8.2.1+tested-with: GHC == 8.4.1, GHC == 8.4.2+ , GHC == 8.2.1, GHC == 8.2.2 , GHC == 8.0.1, GHC == 8.0.2 , GHC == 7.10.1, GHC == 7.10.2, GHC == 7.10.3 , GHC == 7.8.1, GHC == 7.8.2, GHC == 7.8.3, GHC == 7.8.4@@ -29,6 +30,8 @@ Language.SQL.Keyword.Internal.Type build-depends: base >=4.5 && <5+ if impl(ghc < 8)+ build-depends: semigroups hs-source-dirs: src ghc-options: -Wall
src/Language/SQL/Keyword/Internal/Type.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Language.SQL.Keyword.Internal.Type--- Copyright : 2013 Kei Hibino+-- Copyright : 2013-2018 Kei Hibino -- License : BSD3 -- -- Maintainer : ex8k.hibino@gmail.com@@ -19,7 +19,8 @@ import Data.String (IsString(..)) import Data.List (find)-import Data.Monoid (Monoid (..), (<>))+import Data.Semigroup (Semigroup (..))+import Data.Monoid (Monoid (..)) -- | Diff String type for low-cost concatination.@@ -46,12 +47,15 @@ instance Read DString where readsPrec _ s = [(dString s, [])] +dappend :: DString -> DString -> DString+DString f `dappend` DString g = DString $ f . g++instance Semigroup DString where+ (<>) = dappend+ instance Monoid DString where mempty = DString id- DString f `mappend` DString g = DString $ f . g--dspace :: DString-dspace = dString " "+ mappend = dappend -- | Type represent SQL keywords. data Keyword = SELECT | ALL | DISTINCT | ON@@ -130,14 +134,23 @@ found Nothing s = word s found (Just (w, _)) _ = w --- | 'Keyword' default concatination separate by space.-instance Monoid Keyword where- mempty = fromDString mempty- a `mappend` b = fromDString $ toDString a `append'` toDString b where+kappend :: Keyword -> Keyword -> Keyword+a `kappend` b = fromDString $ toDString a `append'` toDString b+ where append' p q | isEmptyDString p = q | isEmptyDString q = p | otherwise = p <> dspace <> q+ dspace :: DString+ dspace = dString " "++instance Semigroup Keyword where+ (<>) = kappend++-- | 'Keyword' default concatination separate by space.+instance Monoid Keyword where+ mempty = fromDString mempty+ mappend = kappend -- | Show 'Keyword'