Case expressions, matching, and "constants"

Mark P Jones mpj@cse.ogi.edu
Thu, 17 Jul 2003 09:25:19 -0700


Hi Alistair,

| I've just debugged a program that used a case expression, but 
| where I was trying to match on constants rather than literals.
| Here's a contrived example:
| 
| > module Main where
| > one = 1
| > two = 2
| >
| > test n =
| >	case n of
| >		one -> "one"
| >		two -> "two"
| >		_ -> "three"
| >
| > main = putStrLn (test 2)

There's a 1992 tech report by Aitken and Reppy that provides a proposal
for doing this kind of thing (and a bit more) in the context of SML:

 ftp://ftp.research.bell-labs.com/dist/smlnj/papers/92-tr-aitken.ps

All the best,
Mark