https://github.com/adetokunbo/redis-glob
A haskell version of the glob used by redis
https://github.com/adetokunbo/redis-glob
haskell haskell-library redis
Last synced: 4 months ago
JSON representation
A haskell version of the glob used by redis
- Host: GitHub
- URL: https://github.com/adetokunbo/redis-glob
- Owner: adetokunbo
- License: bsd-3-clause
- Created: 2022-11-19T12:31:55.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-01-20T06:10:26.000Z (4 months ago)
- Last Synced: 2025-01-31T13:06:10.118Z (4 months ago)
- Topics: haskell, haskell-library, redis
- Language: Haskell
- Homepage: https://hackage.haskell.org/package/redis-glob
- Size: 57.6 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE
Awesome Lists containing this project
README
# redis-glob
[](https://github.com/adetokunbo/redis-glob/actions)
[](http://stackage.org/nightly/package/redis-glob)
[![Hackage][hackage-badge]][hackage]
[![Hackage Dependencies][hackage-deps-badge]][hackage-deps]
[](https://github.com/adetokunbo/redis-glob/blob/master/LICENSE)`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
```haskell
{-# LANGUAGE OverloadedStrings #-}import Redis.Glob
import qualified Data.ByteString.Lazy.Char8 as CLisOK :: 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
```[1]: https://hackage.haskell.org/package/wai
[hackage-deps-badge]:
[hackage-deps]:
[hackage-badge]:
[hackage]:
[KEYS]:
[redis glob]: