# \[ANN\] Tyre - type-safe regular expressions 1.0

**URL:** <https://discuss.ocaml.org/t/ann-tyre-type-safe-regular-expressions-1-0/17584>\
**Category:** Ecosystem\
**Created:** [December 8, 2025, 3:16pm UTC](https://discuss.ocaml.org/t/ann-tyre-type-safe-regular-expressions-1-0/17584 "2025-12-08T15:16:46Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![EmileTrotignon](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/emiletrotignon/32/5913_2.png) [@EmileTrotignon](https://discuss.ocaml.org/u/EmileTrotignon)\
**Post date:** [December 8, 2025, 3:16pm UTC](https://discuss.ocaml.org/t/ann-tyre-type-safe-regular-expressions-1-0/17584/1 "2025-12-08T15:16:46Z")

</div>

I am happy to announce the release of [Tyre](https://github.com/Drup/tyre/) 1.0.

This release makes big changes to the typing: there is a whole host of far more practical combinators allowing you to write code like in a parser combinator library :

```ocaml
let url =
  let+ scheme = opt (const Http (str "http") <|> const Https (str "http") <* str "://") 
  and+ host = rep_any
  and+ port = opt (str ":" *> pos_int)
  and+ path = list (str "/" *> rep_any)
  and+ _ = str "/"
  in
  (scheme, host, port, path)

```

(this is not a correct url parser by any means, its just to give an idea of how you can use this lib)

This does not allow you to use `eval`, because only one direction of the conversion is given (there is no code to convert from a url tuple). However in the cases where you don’t need `eval` this is far easier to write. The difference is typed, you can’t get runtime error by calling eval on the wrong regex.

There are also convencience changes such as charset and the `matched_string` function, that reduce the need to insert `Re` bits in your regexp.

Here is the full changelog:

- Introduce charsets: contrary to `Re`, they have a different type from regex.
- Type the difference between regexps that can be evaluated reversed and the  
ones that cannot: `(evaluable, 'a) Tyre.t` and `(non_evaluable, 'a) Tyre.t`.
- Introduce alias `type pattern` for `(non_evaluable, 'a) Tyre.t`.
- Introduce `val lift : ('a -> string) -> 'a pattern -> ('e, 'a) t` to transform  
a pattern into an expression by giving an explicit conversion function.  
Also `liftpp` that does the same with better performance by using `Format`.
- Introduce `val unlift : (evaluable, 'a) t -> 'a pattern`.
- Introduce `val either: ('e, 'a) Tyre.t -> ('e, 'b) Tyre.t -> ('e, ('a, 'b) Either.t) Tyre.t`.
- Change the type of `alt` to `(_, 'a) t -> (_, 'a) t -> 'a pattern`. Previous  
users of `alt` should switch to `either`.
- Introduce `val alt_eval: ('a -> [`Left | `Right]) -> ('e, 'a) t -> ('e, 'a) t -> ('e, 'a) t`  
This has flat typing but is compatible with `eval`.
- Operators: `<|>` is `alt`, `<||>` is `either`.
- Introduce `val map : ('a -> 'b) -> (_, 'a) t -> 'b pattern` and its  
corresponding operators: `let+` and `<$>`.
- Introduce `(and+)` which is an alias of `seq`.
- Introduce `val app: ('e, 'a -> 'b) t -> ('e, 'a) t -> 'b pattern` and its  
corresponding operator `<*>`
- Introduce `val matched_string : (_, 'a) t -> (_, string) t` that discards the  
computed value and just return the string that was matched.
- Drop dependency on `Result` library. Stdlib is now used.
- Introduce `val rep_charset: Charset.t -> (_, string) t`, and shortcut  
`val rep_any: (_, string) t`.

---

_[View the full topic](https://discuss.ocaml.org/t/ann-tyre-type-safe-regular-expressions-1-0/17584)._
