haskell - Printing Each Character Typed w/ Scalaz -


i'm trying write following haskell function, in scala (using scalaz):

ghci>let f = { x <- getchar; _ <- putchar(x); return () } ghci>f -- type '4' 44ghci> 

here's tried:

def showinput: io[unit] = {     c      <- getchar     _      <- putchar(c) } yield () 

then ran it:

scala> net.repl.foo.showinput res2: scalaz.effect.io[unit] = scalaz.effect.iofunctions$$anon$6@73e3ae3a 

after running method, typed 1234. but, had press enter before output (of 1) showed up:

scala> res2.unsafeperformio 1  

how can write above scalaz function behave identically haskell function?


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -