hw-mquery 0.1.0.0 → 0.1.0.1
raw patch · 6 files changed
+23/−120 lines, 6 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ HaskellWorks.Data.MQuery: count :: MQuery a -> MQuery Int
Files
- LICENSE +17/−26
- README.md +1/−1
- hw-mquery.cabal +2/−2
- src/HaskellWorks/Data/MQuery.hs +3/−55
- src/HaskellWorks/Data/Micro.hs +0/−15
- src/HaskellWorks/Data/Mini.hs +0/−21
LICENSE view
@@ -1,30 +1,21 @@-Copyright John Ky (c) 2016--All rights reserved.--Redistribution and use in source and binary forms, with or without-modification, are permitted provided that the following conditions are met:+MIT License - * Redistributions of source code must retain the above copyright- notice, this list of conditions and the following disclaimer.+Copyright (c) 2016 John Ky - * Redistributions in binary form must reproduce the above- copyright notice, this list of conditions and the following- disclaimer in the documentation and/or other materials provided- with the distribution.+Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions: - * Neither the name of Author name here nor the names of other- contributors may be used to endorse or promote products derived- from this software without specific prior written permission.+The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.
README.md view
@@ -52,7 +52,7 @@ import HaskellWorks.Data.Succinct.RankSelect.Binary.Poppy512 import HaskellWorks.Data.Positioning import qualified Data.Vector.Storable as DVS-import HaskellWorks.Data.Vector.VectorLike+import HaskellWorks.Data.IndexedSeq (jsonBS, jsonIb, jsonBp) <- loadJsonRawWithIndex "firehose.json" let bp1 = SimpleBalancedParens jsonBp let bp2 = SimpleBalancedParens (makePoppy512 jsonBp)
hw-mquery.cabal view
@@ -1,9 +1,9 @@ name: hw-mquery-version: 0.1.0.0+version: 0.1.0.1 synopsis: Conduits for tokenizing streams. description: Please see README.md homepage: http://github.com/haskell-works/hw-mquery#readme-license: BSD3+license: MIT license-file: LICENSE author: John Ky maintainer: newhoggy@gmail.com
src/HaskellWorks/Data/MQuery.hs view
@@ -11,7 +11,6 @@ import qualified Data.DList as DL import GHC.Base import HaskellWorks.Data.Entry--- import HaskellWorks.Data.Json.PartialValue import HaskellWorks.Data.Row import HaskellWorks.Data.ToBool import Text.PrettyPrint.ANSI.Leijen@@ -34,9 +33,6 @@ instance ToBool (MQuery a) where toBool = toBool . mQuery --- instance Pretty (MQuery JsonPartialValue) where--- pretty = pretty . Row 120 . mQuery- instance Pretty (MQuery String) where pretty x = prettyRowOfString (Row 120 (mQuery x)) @@ -46,43 +42,6 @@ instance Pretty (MQuery Int) where pretty x = prettyRowOfString (Row 120 (mQuery x)) --- instance Pretty (MQuery (Entry String JsonPartialValue)) where--- pretty (MQuery das) = pretty (Row 120 das)------ hasKV :: String -> JsonPartialValue -> JsonPartialValue -> MQuery JsonPartialValue--- hasKV k v (JsonPartialObject xs) = if (k, v) `elem` xs then MQuery (DL.singleton (JsonPartialObject xs)) else MQuery DL.empty--- hasKV _ _ _ = MQuery DL.empty------ item :: JsonPartialValue -> MQuery JsonPartialValue--- item jpv = case jpv of--- JsonPartialArray es -> MQuery $ DL.fromList es--- _ -> MQuery DL.empty------ entry :: JsonPartialValue -> MQuery (Entry String JsonPartialValue)--- entry jpv = case jpv of--- JsonPartialObject fs -> MQuery $ DL.fromList (uncurry Entry `map` fs)--- _ -> MQuery DL.empty------ asString :: JsonPartialValue -> MQuery String--- asString jpv = case jpv of--- JsonPartialString s -> MQuery $ DL.singleton s--- _ -> MQuery DL.empty------ asInteger :: JsonPartialValue -> MQuery Integer--- asInteger jpv = case jpv of--- JsonPartialNumber n -> MQuery $ DL.singleton (floor n)--- _ -> MQuery DL.empty------ castAsInteger :: JsonPartialValue -> MQuery Integer--- castAsInteger jpv = case jpv of--- JsonPartialString n -> MQuery $ DL.singleton (read n)--- JsonPartialNumber n -> MQuery $ DL.singleton (floor n)--- _ -> MQuery DL.empty------ named :: String -> Entry String JsonPartialValue -> MQuery JsonPartialValue--- named fieldName (Entry fieldName' jpv) | fieldName == fieldName' = MQuery $ DL.singleton jpv--- named _ _ = MQuery DL.empty- satisfying :: (a -> Bool) -> a -> MQuery a satisfying p a | p a = MQuery $ DL.singleton a satisfying _ _ = MQuery DL.empty@@ -99,20 +58,6 @@ select :: ToBool b => a -> (a -> b) -> MQuery a select a f = if toBool (f a) then MQuery (DL.singleton a) else MQuery DL.empty --- jsonKeys :: JsonPartialValue -> [String]--- jsonKeys jpv = case jpv of--- JsonPartialObject fs -> fst `map` fs--- _ -> []------ hasKey :: String -> JsonPartialValue -> Bool--- hasKey fieldName jpv = fieldName `elem` jsonKeys jpv------ jsonSize :: JsonPartialValue -> MQuery JsonPartialValue--- jsonSize jpv = case jpv of--- JsonPartialArray es -> MQuery (DL.singleton (JsonPartialNumber (fromIntegral (length es))))--- JsonPartialObject es -> MQuery (DL.singleton (JsonPartialNumber (fromIntegral (length es))))--- _ -> MQuery (DL.singleton (JsonPartialNumber 0))- having :: (a -> MQuery b) -> a -> MQuery a having p a = case p a of MQuery das -> case DL.toList das of@@ -136,6 +81,9 @@ onList :: ([a] -> [a]) -> MQuery a -> MQuery a onList f (MQuery xs) = MQuery ((DL.fromList . f . DL.toList) xs)++count :: MQuery a -> MQuery Int+count (MQuery xs) = MQuery (DL.singleton (length (DL.toList xs))) aggregate :: ([a] -> b) -> MQuery a -> MQuery b aggregate f (MQuery xs) = MQuery (DL.fromList [f (DL.toList xs)])
src/HaskellWorks/Data/Micro.hs view
@@ -5,7 +5,6 @@ module HaskellWorks.Data.Micro where import qualified Data.DList as DL--- import HaskellWorks.Data.Json.PartialValue import Text.PrettyPrint.ANSI.Leijen newtype Micro a = Micro a@@ -20,20 +19,6 @@ prettyKvs :: Pretty (Micro a) => [a] -> Doc prettyKvs (kv:kvs) = pretty (Micro kv) <> foldl (<>) empty ((\jv -> text ", " <> pretty (Micro jv)) `map` kvs) prettyKvs [] = empty---- instance Pretty (Micro JsonPartialValue) where--- pretty (Micro (JsonPartialString s )) = dullgreen (text (show s))--- pretty (Micro (JsonPartialNumber n )) = cyan (text (show n))--- pretty (Micro (JsonPartialObject [])) = text "{}"--- pretty (Micro (JsonPartialObject _ )) = text "{..}"--- pretty (Micro (JsonPartialArray [] )) = text "[]"--- pretty (Micro (JsonPartialArray _ )) = text "[..]"--- pretty (Micro (JsonPartialBool w )) = red (text (show w))--- pretty (Micro JsonPartialNull ) = text "null"--- pretty (Micro (JsonPartialError s )) = text "<error " <> text s <> text ">"------ instance Pretty (Micro (String, JsonPartialValue)) where--- pretty (Micro (fieldName, jpv)) = red (text (show fieldName)) <> text ": " <> pretty (Micro jpv) instance Pretty a => Pretty (Micro [a]) where pretty (Micro xs) = case length xs of
src/HaskellWorks/Data/Mini.hs view
@@ -5,7 +5,6 @@ import qualified Data.DList as DL import HaskellWorks.Data.AtLeastSize--- import HaskellWorks.Data.Json.PartialValue import HaskellWorks.Data.Micro import Text.PrettyPrint.ANSI.Leijen @@ -18,23 +17,3 @@ instance Pretty (Mini a) => Pretty (Mini (DL.DList a)) where pretty (Mini xs) = vcat (punctuate (text ",") ((pretty . Mini) `map` take 10 (DL.toList xs)))---- instance Pretty (Mini JsonPartialValue) where--- pretty mjpv = case mjpv of--- Mini (JsonPartialString s ) -> dullgreen (text (show s))--- Mini (JsonPartialNumber n ) -> cyan (text (show n))--- Mini (JsonPartialObject [] ) -> text "{}"--- Mini (JsonPartialObject kvs ) -> case kvs of--- (_:_:_:_:_:_:_:_:_:_:_:_:_) -> text "{" <> prettyKvs kvs <> text ", ..}"--- [] -> text "{}"--- _ -> text "{" <> prettyKvs kvs <> text "}"--- Mini (JsonPartialArray [] ) -> text "[]"--- Mini (JsonPartialArray vs ) | vs `atLeastSize` 11 -> text "[" <> nest 2 (prettyVs (Micro `map` take 10 vs)) <> text ", ..]"--- Mini (JsonPartialArray vs ) | vs `atLeastSize` 1 -> text "[" <> nest 2 (prettyVs (Micro `map` take 10 vs)) <> text "]"--- Mini (JsonPartialArray _ ) -> text "[]"--- Mini (JsonPartialBool w ) -> red (text (show w))--- Mini JsonPartialNull -> text "null"--- Mini (JsonPartialError s ) -> text "<error " <> text s <> text ">"------ instance Pretty (Mini (String, JsonPartialValue)) where--- pretty (Mini (fieldName, jpv)) = text (show fieldName) <> text ": " <> pretty (Mini jpv)