Skip to content

ExnStr doesn't propagate "outwards"

While looking into #8091 (closed) (see ticket:8091#comment:139352) and #13916 (closed), I noticed something that I found rather surprising. Consider this program,

hello :: STM Char -> STM Char
hello a = a `orElse` pure 'a'

Recall that catchRetry# (which orElse is defined in terms of) has the following demand signature,

<xC(S),1*C1(U)><L,1*C1(U)><L,U>

Note the x here: this means it is ExnStr, since it doesn't bottom even if the first argument does (despite the fact that it's strict).

So, the question is this: What demand should hello place on its first argument? I would have thought that it should be precisely the same as the demand that catchRetry# places on **its** first argument. However, the demand analyser seems to conclude this:

<C(S),1*C1(U)>

Note the lack of an x. I believe this may be what causes #13916 (closed).

Edited by Ben Gamari
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information