Eager IO function

2002-02-12 Thread Tom Bevan


How should I modify the function below so that characters are printed
out as they arrive?

Thanks.

Tom


printchar :: Handle -> IO ()
printchar handle = do   c <- hGetChar handle
putChar c

___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: syntax across languages

2002-02-12 Thread Malcolm Wallace

> Being able to specify the extensions required in a source file would be very
> useful in a range of cases. Very often helping other people with Haskell (in
> the case where they are trying to use someone else's module) is just a
> question of saying "try '-98'" or "try '-fglasgow-exts'" or whatever.

ghc and nhc98 already support this.  ghc's mechanism is
{-# OPTIONS -fglasgow-exts ... etc #-}
at the top of the file - but there are quite a few restrictions on
what flags are accepted in that pragma.  nhc98's mechanism is
{-# OPTIONS_COMPILE -nkpat ... etc #-}
anywhere in the file, which has no restrictions on the options it
accepts - you can use anything that can appear on the commandline.

Incidentally, nhc98 also recognises the form
{-# OPTIONS_LINK -L/usr/local/lib -lreadline ... etc #-}
for extra link options, which are accumulated from all modules
specified on the commandline.

Regards,
Malcolm
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: syntax across languages

2002-02-12 Thread Ganesh Sittampalam

On 12 Feb 2002 14:49:16 +0100, Pixel <[EMAIL PROTECTED]> 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
>:-(

Being able to specify the extensions required in a source file would be very
useful in a range of cases. Very often helping other people with Haskell (in
the case where they are trying to use someone else's module) is just a
question of saying "try '-98'" or "try '-fglasgow-exts'" or whatever.

Cheers,

Ganesh
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: syntax across languages

2002-02-12 Thread Pixel


[...]

> (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 :'-(
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe