Shirley Widyaningsih | 1 Jun 2001 01:14
Picon

Information

Dear Sir/Mdm,

  I would like to ask some information about Haskell. For the information, I'm a student that currently
studying at Bina Nusantara University, Jakarta, Indonesia and taking computer science as my subject. In
Indonesia, we've never learned about Haskell. It's not populer in Indonesia, many people don't know
about it. I know it from my friend that studying in Sydney, Australia. I would to install/download this
program, could you give me some info where i can get this software ? If i have to but the software, what is the
software name ? Is it haskell too??
Thank you.

Sincerely,

Shirley

---------------------------------------------
 WANT A NEW JOB? THEN LET THE JOB FIND YOU

 Visit www.ecruit.com.au and register your
 profile. Then the headhunters can find you. 

---------------------------------------------
 Get your own free email account at
 http://www.freemail.com.au/ now part of the 
 Webuser.com.au independent portal. Visit at…
 http://www.webuser.com.au
---------------------------------------------
David Scarlett | 1 Jun 2001 01:43
Picon

Re: Information

Hugs is the standard Haskell interpreter.......
http://www.haskell.org/hugs/

See here for more info on Haskell.....
http://www.haskell.org/

Saswat Anand | 2 Jun 2001 00:25
Picon

fromInteger

Hi,
  I can't understand how the arithmatic operators like (+),(-) are defined and fromInteger works in that context.
 
Type Fun a = Int -> a
 
fun :: Fun Int
fun = (+1)
 
instance (Num a) => Num (Fun a) where
 .........
 
(fun + 2) 10 and (2 + fun) 10 works fine. But how does it know it has to use fromInteger?
 
But If I want these,
  (Just 2 + fun) 10 and (fun + Just 2) 10
to work, then is there a way to tell which conversion function to use?
 
Thanks,
Saswat
 

 
Shirley Widyaningsih | 1 Jun 2001 10:10
Picon

Problem

Dear Sir/Mdm,

    
    I've got some problem here, after i install the hugs98, i want to open file "Fact.hs", but there's an error. 
It's written "ERROR Fact.hs - Unable to open file "Fact.hs" . 
So what should i do???
Thank you.

Sincerely,

Shirley

---------------------------------------------
 WANT A NEW JOB? THEN LET THE JOB FIND YOU

 Visit www.ecruit.com.au and register your
 profile. Then the headhunters can find you. 

---------------------------------------------
 Get your own free email account at
 http://www.freemail.com.au/ now part of the 
 Webuser.com.au independent portal. Visit at…
 http://www.webuser.com.au
---------------------------------------------
Ross Paterson | 1 Jun 2001 12:04
Picon
Favicon

unfoldr in Library Report

While looking through the List module, I came across

   The unfoldr function undoes a foldr operation. Note that, in general,
   only invertible functions can be unfolded.
   [followed by an equation about undoing foldr]

This is quite inadequate: unfoldr is very useful with non-invertible
functions.  I suggest something like:

   The unfoldr function is a `dual' to foldr: while foldr reduces a list
   to a summary value, unfoldr builds a list from a seed value, e.g.,

	iterate f == unfoldr (\x -> Just (x, f x))

   In some cases unfoldr can undo a foldr operation:
   [followed by the existing equation]

Shirley Widyaningsih | 1 Jun 2001 12:08
Picon

Re: Problem


At 01 Jun 2001 11:18:00 +0200, 
Bruno Barbier (barbier <at> comte.univ-fcomte.fr) wrote:
> 
> When hugs is not able to find a file, it says this.
> In the interpreter, type ':?' for help, then you can change the 
> current
> path or update the paths where hugs looks for files.
> 
> 
> 

Can you teach me how to change the current path or updates the paths?
when i go to interpreter-> option, this below are appear.
Current settings: +fewuiA -stgl.qQkR -h250000 -p"%s> " -r$$ -c40
Search path     : -P{Hugs}\lib;{Hugs}\lib\hugs;{Hugs}\lib\exts;{Hugs} \lib\win32
Editor setting  : -EC:\WINDOWS\notepad.exe
Preprocessor    : -F

For the information, my hugs directory is in C:\Program Files\HUGS98
Thank You

Sincerely,

Shirley

---------------------------------------------
 WANT A NEW JOB? THEN LET THE JOB FIND YOU

 Visit www.ecruit.com.au and register your
 profile. Then the headhunters can find you. 

---------------------------------------------
 Get your own free email account at
 http://www.freemail.com.au/ now part of the 
 Webuser.com.au independent portal. Visit at…
 http://www.webuser.com.au
---------------------------------------------
Bruno Barbier | 1 Jun 2001 12:37
Picon

Re: Problem

For hugs related questions, you should write at 
  hugs-users <at> haskell.org

See also 
  http://haskell.org/mailman/listinfo/
for a list of haskell related mailing lists.

For your problem, 
(works fine with linux, but I guess it's the same for Windows)

I do
 :s 
to get the search paths and I get 
 | Search path     : -P{Hugs}/lib:{Hugs}/lib/hugs:{Hugs}/lib/exts

then I type,
 :s -P{Hugs}/lib:{Hugs}/lib/hugs:{Hugs}/lib/exts:mypath1:mypath2

to add the paths 'mypath1' and 'mypath2' into the search paths; 
i.e. absolute paths separated by ':' (for Windows, you should probably use ';')

Shirley Widyaningsih <coldblue <at> freemail.com.au> writes:

> Content-type: text/plain
> 
> 
> 
> At 01 Jun 2001 11:18:00 +0200, 
> Bruno Barbier (barbier <at> comte.univ-fcomte.fr) wrote:
> > 
> > When hugs is not able to find a file, it says this.
> > In the interpreter, type ':?' for help, then you can change the 
> > current
> > path or update the paths where hugs looks for files.
> > 
> > 
> > 
> 
> Can you teach me how to change the current path or updates the paths?
> when i go to interpreter-> option, this below are appear.
> Current settings: +fewuiA -stgl.qQkR -h250000 -p"%s> " -r$$ -c40
> Search path     : -P{Hugs}\lib;{Hugs}\lib\hugs;{Hugs}\lib\exts;{Hugs} \lib\win32
> Editor setting  : -EC:\WINDOWS\notepad.exe
> Preprocessor    : -F
> 
> For the information, my hugs directory is in C:\Program Files\HUGS98
> Thank You
> 
> 
> Sincerely,
> 
> 
> Shirley
> 
> ---------------------------------------------
>  WANT A NEW JOB? THEN LET THE JOB FIND YOU
> 
>  Visit www.ecruit.com.au and register your
>  profile. Then the headhunters can find you. 
> 
> ---------------------------------------------
>  Get your own free email account at
>  http://www.freemail.com.au/ now part of the 
>  Webuser.com.au independent portal. Visit at…
>  http://www.webuser.com.au
> ---------------------------------------------

--

-- 
Bruno Barbier
Laboratoire d'Informatique de Besancon,  Universite de Franche-Comte,  France
Phone/Fax : (33) 381.662.087  / (33) 381.666.450
Mailto    : barbier <at> lifc.univ-fcomte.fr

Steinitz, Dominic J | 1 Jun 2001 17:27
Favicon

Socket Behaviour

Apologies if you have received this request for help already.

Can anyone tell me why the following code doesn't work as expected? Both the server and client hang.

[dom <at> lhrtba8fd85 simptest]$ server 20000 &
[1] 2694
[dom <at> lhrtba8fd85 simptest]$ client lhrtba8fd85 20000
client: interrupted
[1]+  Broken pipe             server 20000
[dom <at> lhrtba8fd85 simptest]$ more log.txt
Starting logging
Hello world
[dom <at> lhrtba8fd85 simptest]$                                                    

So it looks like the hPutStrLn to the server's socket never completes. What's stopping it? On the client
side, "Hello world" gets sent but the hGetLine never completes. I guess because the server for some reason
can't send.

Dominic.

module Main(main) where

import System
import IO
import Socket

main :: IO ()
main = do prog <- getProgName
          args <- getArgs
          if (length args /= 2)
              then do putStrLn ("Use: " ++ prog ++ " <host> <port>")
                      exitWith (ExitFailure (-1))
              else return ()
          let host = args !! 0
              port = read (args !! 1) :: Int in
              client host (PortNumber (mkPortNumber port))

client :: Hostname -> PortID -> IO ()
client host port = 
   do sh <- connectTo host port
      hPutStr sh "Hello world"
      hFlush sh
      x <- hGetLine sh
      putStrLn x

module Main (main) where

import System
import IO
import Socket

main :: IO ()
main = do prog <- getProgName
          args <- getArgs
          if (length args /= 1) 
             then do putStrLn ("Use: " ++ prog ++ " <port>")
                     exitWith (ExitFailure (-1))
             else return ()
          let port = read (args !! 0) :: Int in
             server (PortNumber (mkPortNumber port))

-- The server function creates a socket to listen on the port and
-- loops to log messages. 

server :: PortID -> IO ()
server port = 
   do ofh <- openFile "log.txt" WriteMode
      hPutStrLn ofh "Starting logging"
      hFlush ofh
      socket <- listenOn port 
      (sh,host,portid) <- accept socket
      let loop = do b <- getBuffer sh 16
                    case b of
                       Full msg ->
                          do hPutStrLn ofh msg
                             hFlush ofh
                             loop
                       Partial msg ->
                          do hPutStrLn ofh msg
                             hFlush ofh
                             hPutStrLn sh "Finishing Logging"
                             hFlush sh
                             hPutStrLn ofh "Finishing logging"
                             hClose ofh
         in loop         

data Buffer = Full String | Partial String

getBuffer :: Handle -> Int -> IO Buffer
getBuffer h n =
   if (n <= 0)
      then return (Full "")
      else do x <- try (hGetChar h)
              case x of
                 Right c -> 
                    do xs <- getBuffer h (n-1)
                       case xs of
                          Full cs -> return (Full (c:cs))
                          Partial cs -> return (Partial (c:cs))
                 Left e -> if isEOFError e 
                              then return (Partial "")
                              else ioError e

-------------------------------------------------------------------------------------------------
21st century air travel     http://www.britishairways.com

Marcin 'Qrczak' Kowalczyk | 1 Jun 2001 20:36
Picon

Re: Haskell 98 Report

31 May 2001 16:10:43 -0600, Alastair David Reid <reid <at> cs.utah.edu> pisze:

> and
> 
>   if foo has type
> 
>      foo :: (Ord a) => ty
> 
>   then fooBy has type
> 
>      fooBy :: (a -> a -> Bool) -> ty

It's (a -> a -> Ordering) -> ty, with the default value being
compare.

--

-- 
 __("<  Marcin Kowalczyk * qrczak <at> knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTÊPCZA
QRCZAK

Marcin 'Qrczak' Kowalczyk | 1 Jun 2001 20:34
Picon

Re: fromInteger

Fri, 1 Jun 2001 15:25:24 -0700, Saswat Anand <iscp9157 <at> nus.edu.sg> pisze:

> I can't understand how the arithmatic operators like (+),(-) are =
> defined and fromInteger works in that context.

They are all in class Num. fromInteger is automatically
inserted before all integer literals, e.g. '42' is equivalent to
'fromInteger (42::Integer)' and has type 'Num a => a', i.e. the
context can provide any numeric type and 42 will have that type
by using the appropriate fromInteger.

> Type Fun a = Int -> a
> 
> fun:: Fun Int
> fun = (+1)
> 
> instance (Num a) => Num (Fun a) where
>  .........
> 
> (fun + 2) 10 and (2 + fun) 10 works fine. But how does it know it
> has to use fromInteger?

(+):: Num a => a -> a -> a

>From this type it follows that both arguments of '+' must have the
same type (and that this type must be Num).

The first argument of '+' in 'fun + 2', i.e. 'fun', has a fully
determined type: 'Fun Int'. It follows that the second argument of
'+', i.e. '2', must be 'Fun Int' too.

It's an integral literal, so it can have any Num type. Unifying
'Num a => a' with 'Fun Int' succeeds and gives an answer what 'a'
is here: it's 'Fun Int', and it's ok because it's Num.

> But If I want these,
>   (Just 2 + fun) 10 and (fun + Just 2) 10
> to work, then is there a way to tell which conversion function
> to use?

No: 'Just 2' has type 'Num a => Maybe a', 'fun' has type 'Fun Int',
i.e. 'Int -> Int'. In no way 'Maybe something' can be the same type as
'arg -> result'.

--

-- 
 __("<  Marcin Kowalczyk * qrczak <at> knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTÊPCZA
QRCZAK


Gmane