system call in hugs 
Author Message
 system call in hugs

Hi,

Can anybody explain me how to use the system function in system.hs library?
An example showing

Hugs> system "ls"

in action would help a lot. (All I get is <<IO Action>> right now. How do I
get it take the action?)

Thanks.

-Levent.



Sun, 21 Jan 2001 03:00:00 GMT  
 system call in hugs

Quote:

> Can anybody explain me how to use the system function in system.hs library?
> An example showing

> Hugs> system "ls"

> in action would help a lot. (All I get is <<IO Action>> right now. How do I
> get it take the action?)

The toplevel in Hugs is a little magic.  For usual usage, if the type
of the result is an instance of Show, it's ``shown'' according to the
show rule, e.g.,

  System> "foo"
  "foo"
  System> show "foo"
  "\"foo\""

but if the result is exactly IO (), then the action is run and no
output is printed.  The function `system' returns an error code, thus
you have to get rid of this to get the right type.  Here is one way:

  System> system "ls" >> return ()

The operator `>>' is the monad bind combinator, which ignores the
result of the first monad.  As a syntactic convenience, you can also
write this with a `do'-form:

  System> do system "ls"; return ()

The two are equivalent.

/Tommy



Mon, 22 Jan 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. system calls - file system structure

2. IBM system 370 system call "DMXINV"

3. exploratory system for unix system calls/facilities

4. OZ++ system released with compiler, execution system and management systems

5. Linux system calls from VW

6. Retrieve output from system call

7. Shell environment for system() call

8. Pass Variable into system() call, How to

9. Environment variables inside the system call

10. Thanks - Result of a system() call

11. Result of a system() call

12. Passing an environment variable to a system call within awk

 

 
Powered by phpBB® Forum Software