
1 Nov
2012
1 Nov
'12
3:05 a.m.
On Wed, Oct 31, 2012 at 7:36 PM, Christopher Howard
(This is interesting in and of itself, as I don't in this case have to do pattern matching for each constructor. Also, apparently not all the constructors actually need to have a "range" selector for the program to compile!)
I would avoid using this "feature" of the language, because non-total functions are a hassle.
code: -------- type Range = Double
data Projectile = Bullet Range | Missile Range | Torpedo Range
f (_ r) = ... --------
Nope, you can't do that. But you can do this: data ProjectileType = Bullet | Missile | Torpedo data Projectile = Projectile ProjectileType Range f (Projectile _ r) = ... -Karl