syntax across languages
Pixel
pixel@mandrakesoft.com
12 Feb 2002 14:49:16 +0100
[...]
> (I guess its a cousin to templates in C++)
> Or perhaps you need a separate section for syntax
> for constructing new datatypes..
yes, i think so. With enums and ranges being a special case.
i'll also put records
[...]
> (Please dont take this as an insult by my re-explaining these things.
> I just want to make myself clear.)
the pb is that the semantic is so different between the languages. So i just
put all of them with no explaination.
> > > Under constrol structure, at least give mention to monads!
> > > Common examples (ST,IO,List,Maybe) and "do notation"
> > >
> > > Monads are defined by instanciating them under the Monad type class.
> > > (basically giving definitions for the operators >>= (aka 'bind') and >>
> >
> > please be more precise, what do i put? in which category?
>
> I guess I suggested control structure because in a way, you can "control
> the flow" from a semantic point of view of your program by building /
> choosing a specific monad. For instance, usage of the List monad brings
> nondeterminism into the language (although, in reality,
> the multiple solutions alluded to by the term are elements of a
> deterministically (is that a word?!) produced list)
"syntax across languages" is about syntax!
If something needs much explaination, it can't be included :p
[...]
> I suppose a sollution to what to do with do-notation is to put something
> like
> [...]
> or do {stmnt; var <-stmtn; etc}
>
> under your section named "Various Operators" with description
> "do statments under monad"
I don't accept entries where only one language fits in :p
(this may change as soon as monads appear in more languages)
[...]
> > > References arent missing. They are implemented under both the ST and IO
> > > monads.
> >
> > what is the syntax?
>
> no syntax, only functions which create/manipulate them (under some monad).
>
> do{ x<-newSTRef exp; y <-readSTRef x; writeSTRef x exp}
>
> for IORefs do s/ST/IO/g to above line.
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
:-(
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?
PS: show $ runST $ do { x <- newSTRef 2; writeSTRef x 3 ; readSTRef x }
is not working :'-(