syntax across languages

Jay Cox sqrtofone@yahoo.com
Wed, 13 Feb 2002 09:53:09 -0600 (CST)


On 12 Feb 2002, Pixel wrote:

> eurk
>
> ERROR "/usr/share/hugs/lib/exts/ST.hs":48 - Syntax error in type expression (unexpected `.')
>
> isn't there a way ST.hs would require the extensions? a pragma or something?
> someone not knowing the "-98" would wonder for a long time about what to do
> :-(
>

That could be nice, at least for ST.hs  (in ghc the equivalent of
hugs option "-98" isn't needed)


> anyway, the simplest examples i found:
>
> show $ runST (do { x <- newSTRef 2; writeSTRef x 3 ; readSTRef x })
>
> so i can write:
>
> newSTRef  in "reference (pointer)" "creation"
> readSTRef writeSTRef  in "reference (pointer)" "dereference"
>
> WDYT?

If you understand your explanations for newSTRef etc. that's fine with me.
My code in this thread  (which coincidentally is a no-op) emphasizes which
ones you would use "<-" with.  So let me make one final adjustment so
that:

do{ x<-newSTRef 3; y <-readSTRef x; writeSTRef x (y+4);readSTRef x}

Too long?

> PS: show $ runST $ do { x <- newSTRef 2; writeSTRef x 3 ; readSTRef x }
>       is not working :'-(
> _______________________________________________

Does typing in the following work?

runST (do { x <- newSTRef 2; writeSTRef x 3 ; readSTRef x })

I can't explain and dont understand the error I get from the compiler with
your code.  (the haskell compilers I've used are not very helpful in error
messages)

Btw to get it to work in ghci you'd have to
start:
1. ghci -package lang
2. load in some dummy file with 2 lines
(so both Prelude and ST functions are available)
...(lines starting below!)....
import ST
main = print "hi"
....(lines ending)......
3. type in runST ( ... )


Somebody would have to fill in the details for me about doing stuff in
hugs.


Jay