homepage: ''
changelog-type: markdown
hash: e71af3441394ec6ff6c3ec1fee4cab83947ab218257b098294e240c80f3b11f2
test-bench-deps: {}
maintainer: lukec@themk.net
synopsis: Types that can only be constructed if they match a regular expression
changelog: |
  # Revision history for regex-wrapper

  ## 0.1.0.0 -- 2019-11-11

  * Initial Version released.
basic-deps:
  bytestring: -any
  case-insensitive: -any
  base: ^>=4.12.0.0
  text: -any
  containers: -any
  string-conv: -any
  regex-tdfa: -any
  hashable: -any
  aeson: -any
all-versions:
- 0.1.0.0
author: Luke Clifton
latest: 0.1.0.0
description-type: markdown
description: |
  ### Experimental

  This library allows you to create types that are guaranteed to contain a
  string that matches a given regular expression which is expressed at the
  type level.

  ```haskell
  newtype User = User (Matched String "^[a-zA-Z0-9]{4,15}$")

  parseUser :: String -> Either (RegexError String) User
  parseUser = fmap User . parseMatchedEither

  prettyUser :: User -> String
  prettyUser (User m) = asString m

  main :: IO ()
  main = do
      l <- getLine
      case parseUser l of
          Right user -> putStrLn $ "Hello, " ++ prettyUser user ++ "!"
          Left error -> putStrLn $ "Could not parse username: " ++ prettyRegexError  error
  ```

  ```
  ./prog
  bad
  Could not parse username: The input "bad" did not match the pattern ^[a-zA-Z0-9]{4,15}$
  ```

  ```
  ./prog
  good
  Hello, good!
  ```
license-name: BSD-3-Clause

Update from Hackage at 2019-11-11T03:12:56Z
Update from Hackage at 2019-11-11T03:12:56Z
