You might like this talk [1] about building a better regex library using dependent type style features. It is really great! The regex is parsed at compile time and then can return better typed information about the capture groups to the lib user. There is also this interview I did with the author on it [2]
[1] https://thestrangeloop.com/2017/dependent-types-in-haskell.h...
[2] https://corecursive.com/015-dependant-types-in-haskell-with-...