BSD-3-Clause licensed by Tim Emiola
Maintained by [email protected]
This version can be pinned in stack with:redis-glob-0.1.0.8@sha256:b90e24129287caa935dc2cfc9a663afdcd0062296860cf8b898b47d93806bf96,2101

Module documentation for 0.1.0.8

Used by 1 package in nightly-2024-04-25(full list with versions):

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

Changes

Revision history for redis-glob

redis-glob uses PVP Versioning.

0.1.0.8 – 2024-02-28

  • Expand upper bounds for bytestring

0.1.0.7 – 2024-01-03

  • Expand upper bounds for megaparsec

0.1.0.6 – 2023-09-01

  • Expand upper bounds for megaparsec

0.1.0.5 – 2023-07-12

  • Expand dependency upper bounds for bytestring and megaparsec

0.1.0.4 – 2023-01-07

  • Remove dependency on ascii-superset

0.1.0.3 – 2023-01-05

  • Relax dependencies

0.1.0.2 – 2022-11-21

  • Tweak package metadata

0.1.0.1 – 2022-11-21

  • Tweak developer tools, CI and package metadata

0.1.0.0 – 2022-11-21

  • Initial version.