redis-glob: Specify valid redis globs

[ bsd3, library, redis, web ] [ Propose Tags ] [ Report a vulnerability ]

Supplies functions that parse and use redis glob patterns. As in redis commands like KEYS, that filter using globs.


[Skip to Readme]

Flags

Automatic Flags
NameDescriptionDefault
use-doc-tests

Run the doctests

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.1.0.4, 0.1.0.5, 0.1.0.6, 0.1.0.7, 0.1.0.8
Change log ChangeLog.md
Dependencies ascii-char (>=1.0.1 && <1.1), base (>=4.11 && <5.0), bytestring (>=0.10.8.2 && <0.11 || >=0.11.3.1 && <0.12.2), megaparsec (>=9.2.1 && <9.7) [details]
Tested with ghc ==8.10.7 || ==9.0.2 || ==9.2.4 || ==9.4.1
License BSD-3-Clause
Author Tim Emiola
Maintainer adetokunbo@emio.la
Category Web, Redis
Home page https://github.com/adetokunbo/redis-glob#readme
Bug tracker https://github.com/adetokunbo/redis-glob/issues
Source repo head: git clone https://github.com/adetokunbo/redis-glob.git
Uploaded by adetokunbo at 2024-02-29T07:33:14Z
Distributions LTSHaskell:0.1.0.8, NixOS:0.1.0.8
Reverse Dependencies 1 direct, 3 indirect [details]
Downloads 615 total (16 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2024-02-29 [all 1 reports]

Readme for redis-glob-0.1.0.8

[back to package description]

redis-glob

GitHub CI Stackage Nightly Hackage Hackage Dependencies BSD3

redis-glob checks that glob expressions for use with Redis are valid. Redis commands like KEYS use glob expressions to match keys in redis.

If the glob expression is invalid, the command returns an empty result, which unfortunately is the same as if the expression was valid but had no results.

Use validate to confirm if a glob expression is valid. It parses the expression in the same way as the actual redis glob implementation, returning Nothing for invalid expressions.

matches can be used to confirm that a bytestring matches a glob expression if the the glob expression is valid.

Example

{-# LANGUAGE OverloadedStrings #-}

import Redis.Glob
import qualified Data.ByteString.Lazy.Char8 as CL


isOK :: CL.ByteString -> IO ()
isOk b = do
  CL.putStrLn $ "Is " <> b <> " ok? " <> maybe "n" (const "y") (validate b)
  CL.putStrLn $ "Does it match hello? " <> if (b `matches` "hello") then "y" else "n"

main :: IO()
main = do
  isOK "h?llo"     -- Is h?llo ok? y
                   -- Does it match hello? y
  isOK "y[a-b]llo" -- Is y[a-b]llo ok? y"
                   -- Does it match hello? n
  isOK "h[a-]llo"  -- Is h[a-]llo ok? n
                   -- Does it match hello? n