- Notifications
You must be signed in to change notification settings - Fork 12
Closed
Description
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 regex-tdfa/lib/Text/Regex/TDFA/Pattern.hs
Lines 98 to 110 in 95d47cb
| instance Show PatternSet where | |
| showsPrec i (PatternSet s scc sce sec) = | |
| let (special,normal) = maybe ("","") ((partition (`elem` "]-")) . Set.toAscList) s | |
| charSpec = (if ']' `elem` special then (']':) else id) (byRange normal) | |
| scc' = maybe "" ((concatMap show) . Set.toList) scc | |
| sce' = maybe "" ((concatMap show) . Set.toList) sce | |
| sec' = maybe "" ((concatMap show) . Set.toList) sec | |
| in shows charSpec | |
| . showsPrec i scc' . showsPrec i sce' . showsPrec i sec' | |
| . if '-' `elem` special then showChar '-' else id | |
| where byRange xAll@(x:xs) | length xAll <=3 = xAll | |
| | otherwise = groupRange x 1 xs | |
| byRange _ = undefined |
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?
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working