#2431: allow empty case analysis
---------------------------------+------------------------------------------
Reporter: RalfHinze | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.8.3
Severity: minor | Resolution:
Keywords: empty case analysis | Difficulty: Unknown
Testcase: | Architecture: Unknown
Os: Unknown |
---------------------------------+------------------------------------------
Comment (by NeilMitchell):
This would be somewhat useful for the Derive tool
(http://www.cs.york.ac.uk/fp/darcs/derive), and in general for program
generation. Consider the automatically derived instance for Show, on an
empty data type. What you are likely to get is:
{{{
instance Show Void where
}}}
i.e. the complete absense of anything. If you changed the generator to
make a case statement, you could get:
{{{
instance Show Void where
show x = case x of {}
}}}
Which is a more accurate reflection of what was intended, and I think the
point Ralf is trying to make. Derive probably goes wrong with empty data
types, but if it didn't, this extension would be helpful.
I tried to construct an empty case with Template Haskell, and crashed GHC:
{{{
C:\Neil\Temp>ghci -fth
GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help
Loading package base ... linking ... done.
Prelude> :m Language.Haskell.TH
Prelude Language.Haskell.TH> $(caseE (litE $ CharL 'a') [])
: panic! (the 'impossible' happened)
(GHC version 6.8.2 for i386-unknown-mingw32):
readFilledBox t_a1b5{tv} [box]
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2431#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs