... | @@ -313,6 +313,55 @@ Note that the bang has no effect at all in this case |
... | @@ -313,6 +313,55 @@ Note that the bang has no effect at all in this case |
|
|
|
|
|
With `-XStrict` the `~` is used to recover ordinary patterns, to build an irrefutable pattern `~~` is used.
|
|
With `-XStrict` the `~` is used to recover ordinary patterns, to build an irrefutable pattern `~~` is used.
|
|
|
|
|
|
## Implementation
|
|
## Implementation notes
|
|
|
|
|
|
TODO Find all the places where we do special things for bang patterns and list them here. |
|
|
|
|
|
Implementation notes
|
|
|
|
|
|
|
|
|
|
|
|
Consider a recursive group like this
|
|
|
|
|
|
|
|
```wiki
|
|
|
|
letrec
|
|
|
|
f : g = rhs[f,g]
|
|
|
|
in <body>
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
Without `Strict`, we get a translation like this:
|
|
|
|
|
|
|
|
```wiki
|
|
|
|
let t = /\a. letrec tm = rhs[fm,gm]
|
|
|
|
fm = case t of fm:_ -> fm
|
|
|
|
gm = case t of _:gm -> gm
|
|
|
|
in
|
|
|
|
(fm,gm)
|
|
|
|
|
|
|
|
in let f = /\a. case t a of (fm,_) -> fm
|
|
|
|
in let g = /\a. case t a of (_,gm) -> gm
|
|
|
|
in <body>
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
Here `tm` is the monomorphic binding for `rhs`.
|
|
|
|
|
|
|
|
|
|
|
|
With `Strict`, we want to force `tm`, but NOT `fm` or `gm`.
|
|
|
|
Alas, `tm` isn't in scope in the `in <body>` part.
|
|
|
|
|
|
|
|
|
|
|
|
The simplest thing is to return it in the polymoprhic
|
|
|
|
tuple `t`, thus:
|
|
|
|
|
|
|
|
```wiki
|
|
|
|
let t = /\a. letrec tm = rhs[fm,gm]
|
|
|
|
fm = case t of fm:_ -> fm
|
|
|
|
gm = case t of _:gm -> gm
|
|
|
|
in
|
|
|
|
(tm, fm, gm)
|
|
|
|
|
|
|
|
in let f = /\a. case t a of (_,fm,_) -> fm
|
|
|
|
in let g = /\a. case t a of (_,_,gm) -> gm
|
|
|
|
in let tm = /\a. case t a of (tm,_,_) -> tm
|
|
|
|
in tm `seq` <body>
|
|
|
|
``` |
|
|
|
\ No newline at end of file |