haskell-hvr / regex-tdfa

Pure Haskell Tagged DFA Backend for "Text.Regex" (regex-base)
http://hackage.haskell.org/package/regex-tdfa
Other
36 stars 9 forks source link

`Show PatternSet` throws `undefined` #37

Closed andreasabel closed 2 years ago

andreasabel commented 2 years ago

undefined in a Show instance, congratulations!

$ cabal repl

ghci> :m +Text.Regex.TDFA.ReadRegex

ghci> parseRegex "[[:digit:]]"

Right (POr [PConcat [PAny {getDoPa = #1, getPatternSet = "*** Exception: Prelude.undefined
CallStack (from HasCallStack):
  error, called at libraries/base/GHC/Err.hs:74:14 in base:GHC.Err
  undefined, called at lib/Text/Regex/TDFA/Pattern.hs:110:23 in regex-tdfa-1.3.1.2-inplace:Text.Regex.TDFA.Pattern

https://github.com/haskell-hvr/regex-tdfa/blob/95d47cb982d2cf636b2cb6260a866f9907341c45/lib/Text/Regex/TDFA/Pattern.hs#L98-L110

THOU SHALT NOT ABUSE THE Show CLASS! Show is to print the HASKELL representation of data, not anything nice for the user!

How is one to explore a package if it tampers with Show, esp. in a way that crashes?