I was reading in the source code, and this next really didnt look
right to me, so maybe one of the maintainers should look at this code
again. I'm posting this to -users because I'm not subscribed
to -bugs.
from a recently downloaded copy of fptools/hslibs/lang/ST.lhs:
>#ifdef __HUGS__
>fixST :: (a -> ST s a) -> ST s a
>fixST m = ST (\ s ->
> let
> (r,s) = unST (m r) s
> in
> (r,s))
s is bound in 2 places here: in the \-abstraction and in the @let@.
by the definition of @let@ on page 22 of the Report, we can change
that to this next, which emphasizes the fact that the inner binding
is in effect on the RHS:
>fixST m = ST (\ s ->
> let
> (r,s) = fix (\~(r,s)->unST (m r) s)
> in
> (r,s))
notice that the outer binding is never used. eg, that last is
equivalent to this next.
>fixST m = ST (\ _ ->
> let
> (r,s) = unST (m r) s
> in
> (r,s))
but the non-Hugs definition of the same function uses that outer binding:
>fixST k = ST $ \ s ->
> let ans = liftST (k r) s
> STret _ r = ans
> in
> case ans of STret s' x -> (# s', x #)
this leads me to believe that one of the 2 definitions is wrong.