| ... | ... | @@ -234,3 +234,32 @@ Concrete proposal: a default decl can occur anywhere that a type signature woul |
|
|
|
### Cons
|
|
|
|
|
|
|
|
- Changes the Haskell'98 behaviour (where defaults are module-local). Question: Do any real programs actually rely on the Haskell'98 spec here?
|
|
|
|
|
|
|
|
## Proposal 4 - remove defaulting
|
|
|
|
|
|
|
|
|
|
|
|
It is generally agreed that defaulting, in its current form at least, is a wart on the language. The main motivation behind it is to make simple calculator-like uses of interactive Haskell environments possible.
|
|
|
|
|
|
|
|
|
|
|
|
This proposal, then, is to remove defaulting from the language; we would expect that interactive environments will continue to default as they think best. Note that implementations already go beyond what is stated in the report when defaulting.
|
|
|
|
|
|
|
|
|
|
|
|
Most(?) instances of defaulting in Real Programs are due to (\^). If this proposal is adopted then we would recommend changing the type of (\^) and introducing genericPower (or some better name) thus:
|
|
|
|
|
|
|
|
```wiki
|
|
|
|
(^) :: (Num a) => a -> Int -> a
|
|
|
|
genericPower :: (Num a, Integral b) => a -> b -> a
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
This is similar to the scheme used by, for example, genericIndex.
|
|
|
|
|
|
|
|
### Pros
|
|
|
|
|
|
|
|
- Easy to implement and explain.
|
|
|
|
- Makes the language smaller.
|
|
|
|
- Trivially fixes any problems tools like hat have with defaulting.
|
|
|
|
|
|
|
|
### Cons
|
|
|
|
|
|
|
|
- No pretense at trying to remain compatible with Haskell '98, but how many uses of defaulting are there in the wild? And how many not covered by (\^)? |