Re: [Haskell-cafe] Haskell Weekly News: Issue 85 - September 13, 2008

2008-09-14 Thread Brandon S. Allbery KF8NH

On 2008 Sep 14, at 1:24, Daryoush Mehrtash wrote:
What I am trying to figure out is that say on the code for the IRC  
bot that is show here


http://www.haskell.org/haskellwiki/Roll_your_own_IRC_bot/Source

What would theorem proofs do for me?



Assurance of correct operation; for example, a mathematically provable  
lack of security holes, assuming you can describe its proper operation  
in terms of suitable theorems (which, for a simple bot like that, is  
not so difficult).


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] static linking failure -- can't find crt0

2008-09-14 Thread Jason Dusek
  I'm building a really static executable on OS X with options
  `-optl-static -static` and, while the libraries seem to link
  fine, the executable itself does not -- it can't find the C
  runtime.

  This is actually by design -- Apple does not support static
  binaries. There is a work around -- just symlink stuff till
  the errors go away -- but it might be better if I could
  statically link only those C libraries that I knew were not on
  stock Macs. Are there GHC options for that?

  I assume this all works fine on Linux and Windows, but I'll
  know soon enough...

--
_jsn


 |...can't find the C runtime.|
  ld_classic: can't locate file for: -lcrt0.o
  collect2: ld returned 1 exit status

 |does not support|
  http://developer.apple.com/qa/qa2001/qa1118.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Hugs on the iphone

2008-09-14 Thread Alberto R. Galdo

Hi, is there any chance of having hugs  compile for the iPhone?

Cross-compiling? Compiling directly on the iPhone?

Greets,
Alberto
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell Weekly News: Issue 85 - September 13, 2008

2008-09-14 Thread Rafael Almeida
On Sun, Sep 14, 2008 at 5:56 AM, Thomas M. DuBuisson
[EMAIL PROTECTED] wrote:

 What would theorem proofs do for me?
 Imagine if you used SmallCheck to exhastively test the ENTIRE problem
 space for a given property.  Now imagine you used your brain to show the
 programs correctness before the heat death of the universe...

 Proofs are not features, nor are they code.  What you prove is entirely
 up to you and might not be what you think.  Take, for example, the issue
 of proving a sort function works correctly [1].

 I'm not saying this to discourage complete proofs, but just cautioning
 you that proving something as unimportant and IO laden as an IRC bot
 probably isn't the best example.  Do see the linked PDF, and [2] as
 well.

 Oh, and for examples where people should have used FM, search for
 'ariane 1996'  or the gulf war patriot missle failure

 TomMD

 [1]
 http://www.cl.cam.ac.uk/~mjcg/Teaching/SpecVer1/Lectures/pslides07x4.pdf
 [2] http://users.lava.net/~newsham/formal/reverse/


One thing have always bugged me: how do you prove that you have
correctly proven something? I mean, when I write a code I'm formaly
stating what I want to happen and bugs happen. If I try to prove some
part of the code I write more formal text (which generally isn't even
checked by a compiler); how can I be sure that my proof doesn't
contain bugs? Why would it make my program less error-prone? Is there
any article that tries to compare heavy testing with FM?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: pandoc 1.0.0.1

2008-09-14 Thread Max Bolingbroke
2008/9/14 John Goerzen [EMAIL PROTECTED]:
 2) Variable x defined but not used

 I most often ignore this when it occurs in a function definition.
 Sometimes I may have a function that could be written

 foo _ (x, _) _ = bar (x + 5)

 But for clarity's sake on what all the unused args are, which really
 helps for future maintainability, I'll usually use a descriptive --
 but unused -- variable name.

This doesn't appear to be commonly known, but actually any identifier
that /starts/ with an _ will not trigger the unused-arg warning. So if
you wrote your example like this:

foo _stuff (x, _y) _more = bar (x + 5)

It would satisfy both the compiler and your desire for descriptive
variable names.

Cheers,
Max
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell Weekly News: Issue 85 - September 13, 2008

2008-09-14 Thread Chaddaï Fouché
2008/9/14 Rafael Almeida [EMAIL PROTECTED]:

 One thing have always bugged me: how do you prove that you have
 correctly proven something? I mean, when I write a code I'm formaly
 stating what I want to happen and bugs happen. If I try to prove some
 part of the code I write more formal text (which generally isn't even
 checked by a compiler); how can I be sure that my proof doesn't
 contain bugs? Why would it make my program less error-prone? Is there
 any article that tries to compare heavy testing with FM?

Well, that's where formal prover enter the picture : when you prove
something with Coq, you can be reasonably sure that your proof is
correct. And FM brings absolute certitude a propriety is verified by
your program whereas testing however heavy can only check this
property on a finite set of inputs (using randomly generated input
help alleviate the risk of blind spot but is still limited).

-- 
Jedaï
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Views

2008-09-14 Thread Johannes Waldmann



I think the crux of
the matter was that a monad is too general. Either there is a result or
there is not. That's precisely the intended use of a Maybe.


Indeed Monad m = is dangerous here
because not every Monad has a reasonable definition of fail.

But that seems to be a problem in the (current) definition of Monad,
and its solution was MonadZero, no?

J.W.



signature.asc
Description: OpenPGP digital signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Views

2008-09-14 Thread Stephan Friedrichs
Johannes Waldmann wrote:
 a) ... to use Maybe
 b) ... to provide my own Data.Heap.View type
 
 leave the choice up to the programmer,
 and provide a generic interface,
 accepting any MonadZero (*) instance.
 
 cf. Data.Set.maxView

AFAIK there has been a vivid discussion about that. I think the crux of
the matter was that a monad is too general. Either there is a result or
there is not. That's precisely the intended use of a Maybe.

Besides, I just learned that Data.Map.{lookup,minView,maxView} and the
like have been modified to return a Maybe in the current GHC head
branch, see [1]. This suggests using Maybe in my case as well.

 
 [...]
 

[1]
http://www.haskell.org/ghc/dist/current/docs/libraries/containers/Data-Map.html

-- 

Früher hieß es ja: Ich denke, also bin ich.
Heute weiß man: Es geht auch so.

 - Dieter Nuhr
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: [Haskell] Heads Up: code.haskell.org is upgrading to darcs 2

2008-09-14 Thread Neil Mitchell
Hi

Ignore the previous email message, as soon as I sent the email it
started working - I guess it was just code.haskell.org server issues.

Thanks

Neil

On 9/14/08, Neil Mitchell [EMAIL PROTECTED] wrote:
 Hi

  I'm currently unable to push to [EMAIL PROTECTED]:/srv/code/hoogle
  using darcs 1.0.9 on Windows Vista, and wasn't able to yesterday
  either.  Is code.haskell.org just being slow, or is there a chance
  that Hoogle suffered as a result of the upgrade?

  Thanks


  Neil


  On 9/11/08, Eric Y. Kow [EMAIL PROTECTED] wrote:
We are upgrading /usr/bin/darcs to version 2 on the machine that hosts
 code.haskell.org.

 That means it will be used by everyone who uses ssh to push or pull from
 a darcs repository on code.haskell.org. Pulling via http is completely
 unaffected.
  
  
   Thanks Duncan!  Now my hope is that we can encourage the good folk at
Galois to make a similar upgrade for darcs.haskell.org
  
  
--
Eric Kow http://www.nltg.brighton.ac.uk/home/Eric.Kow
PGP Key ID: 08AC04F9
  

  ___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
  
  
  

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Views

2008-09-14 Thread Stephan Friedrichs
Johannes Waldmann wrote:
 I think the crux of
 the matter was that a monad is too general. Either there is a result or
 there is not. That's precisely the intended use of a Maybe.
 
 Indeed Monad m = is dangerous here
 because not every Monad has a reasonable definition of fail.
 
 But that seems to be a problem in the (current) definition of Monad,
 and its solution was MonadZero, no?

I agree that the MonadZero class with a useful 'zero' :: m a would be
the right abstraction for views. But MonadZero is not part of base, mtl
or any other common package, or am I missing something? Changing this is
beyond a simple heap package ;)

-- 

Früher hieß es ja: Ich denke, also bin ich.
Heute weiß man: Es geht auch so.

 - Dieter Nuhr
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Hugs on the iphone

2008-09-14 Thread Braden Shepherdson

Alberto R. Galdo wrote:

Hi, is there any chance of having hugs  compile for the iPhone?

Cross-compiling? Compiling directly on the iPhone?

Greets,
Alberto


The iPhone, like most modern mobile devices, is based on the ARM 
processor, for which there is currently no GHC port.


However, jhc outputs portable C code which can be (cross) compiled for 
ARM. I have succeeded in building Haskell code with jhc on my desktop 
(x86 Linux), then cross-compiling the resulting C code in a scratchbox 
environment for my Nokia N810.


In short, if you can compile C code for the iPhone (cross-compiled or 
native), you can probably use jhc to turn Haskell into suitable C.


jhc is not self-hosting, and it requires gcc as a back-end, so it isn't 
suitable for running on the device.


See also the GHC-on-ARM project[1], an attempt to port GHC to ARM Linux 
devices.



Braden Shepherdson
shepheb

[1] http://hackage.haskell.org/trac/ghc/wiki/ArmLinuxGhc

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Hugs on the iphone

2008-09-14 Thread Braden Shepherdson

Braden Shepherdson wrote:

Alberto R. Galdo wrote:

Hi, is there any chance of having hugs  compile for the iPhone?

Cross-compiling? Compiling directly on the iPhone?

Greets,
Alberto


The iPhone, like most modern mobile devices, is based on the ARM 
processor, for which there is currently no GHC port.


However, jhc outputs portable C code which can be (cross) compiled for 
ARM. I have succeeded in building Haskell code with jhc on my desktop 
(x86 Linux), then cross-compiling the resulting C code in a scratchbox 
environment for my Nokia N810.


In short, if you can compile C code for the iPhone (cross-compiled or 
native), you can probably use jhc to turn Haskell into suitable C.


jhc is not self-hosting, and it requires gcc as a back-end, so it isn't 
suitable for running on the device.


See also the GHC-on-ARM project[1], an attempt to port GHC to ARM Linux 
devices.



Braden Shepherdson
shepheb

[1] http://hackage.haskell.org/trac/ghc/wiki/ArmLinuxGhc



I failed completely to mention Hugs: I don't think it exists, but I 
think someone managed to port it to the Nintendo DS a while back, so it 
should be possible.



Braden Shepherdson
shepheb

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: [Haskell] Heads Up: code.haskell.org is upgrading to darcs 2

2008-09-14 Thread Duncan Coutts
On Sun, 2008-09-14 at 14:41 +0100, Neil Mitchell wrote:
 Hi
 
 Ignore the previous email message, as soon as I sent the email it
 started working - I guess it was just code.haskell.org server issues.

Yes it was unavailable for a short time yesterday. It got rebooted by
the hosting company, we're not exactly sure why.

Duncan

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell Weekly News: Issue 85 - September 13, 2008

2008-09-14 Thread Dan Doel
On Sunday 14 September 2008 6:59:06 am Rafael Almeida wrote:
 One thing have always bugged me: how do you prove that you have
 correctly proven something? I mean, when I write a code I'm formaly
 stating what I want to happen and bugs happen. If I try to prove some
 part of the code I write more formal text (which generally isn't even
 checked by a compiler); how can I be sure that my proof doesn't
 contain bugs? Why would it make my program less error-prone? Is there
 any article that tries to compare heavy testing with FM?

This isn't really a problem if you're programming in a language in which the 
proofs of program correctness are checked by the compiler/what have you, as 
Chaddaï has already said. In that case, it's similar to asking, how do I know 
my Haskell programs are actually type correct? Barring bugs in the tools 
(which, in the ideal case, are built on a simple enough foundation to be 
confidently proven correct by hand), it's not so much a concern.

A more difficult question is: how do I know that the formal specification I've 
written for my program is the right one? Tools can fairly easily check that 
your programs conform to a given specification, but they cannot (to my 
knowledge) check that your specification says exactly what you want it to say.

Of course, this is no worse than the case with test suites, since one can 
similarly ask, how can I be sure the tests check for the properties/behavior 
that I actually want?

-- Dan
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] system in forkIO

2008-09-14 Thread Marco Túlio Gontijo e Silva
Hello.

 import System.Cmd
 import GHC.Conc
 
 main :: IO ()
 main
   = forkIO
 ( do
 putStrLn fork
 system ls
 return ())
  getChar
  return ()

When I run this code, I get

fork

and the result of ls only after I press a key.  Does getChar blocks the
other threads?

Greetings.

-- 
marcot
Página: http://marcotmarcot.iaaeee.org/
Blog: http://marcotmarcot.blogspot.com/
Correio: [EMAIL PROTECTED]
XMPP: [EMAIL PROTECTED]
IRC: [EMAIL PROTECTED]
Telefone: 25151920
Celular: 98116720
Endereço:
  Rua Turfa, 639/701
  Prado 30410-370
  Belo Horizonte/MG Brasil


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] system in forkIO

2008-09-14 Thread Andrea Rossato
On Sun, Sep 14, 2008 at 02:24:23PM -0300, Marco Túlio Gontijo e Silva wrote:
 and the result of ls only after I press a key.  Does getChar blocks the
 other threads?

yes, but you can use forkOS from Control.Concurrent and compile with
-threaded.

See the relevant documentation for the details.

Hope this helps,
Andrea
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] system in forkIO

2008-09-14 Thread Judah Jacobson
On Sun, Sep 14, 2008 at 10:24 AM, Marco Túlio Gontijo e Silva
[EMAIL PROTECTED] wrote:

 When I run this code, I get

 fork

 and the result of ls only after I press a key.  Does getChar blocks the
 other threads?


I think this behavior is caused by (or at least related to) the
following GHC bug:

http://hackage.haskell.org/trac/ghc/ticket/2363

That bug has been fixed for the 6.10 release; my testing indicated
that your program behaves correctly in that version.  See the above
bug report for some suggestions on how to work around the 6.8 getChar
blocking.

Hope that helps,
-Judah
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] message passing style in Monad

2008-09-14 Thread Simon Richard Clarkstone

jinjing wrote:

I found that as I can do

  xs.map(+1).sort

by redefine . to be

  a . f = f a
  infixl 9 .


This looks rather like ($), but backwards.  I believe the F# name for 
this operator is (|), which is also a legal name for it in Haskell. 
Odd, since (|) alone isn't legal.  Calling it (.) will confuse the heck 
out of anyone who maintains your code though, and make any transfer of 
code between your projects and other people's liable to introduce bugs.



I can also do

  readFile readme.markdown . lines . length

by making

  a . b = a .liftM b
  infixl 9 .

Kinda annoying, but the option is there.


Now that looks more interesting.  Another name for it is (=^), since 
it is like (=) but lifts its right argument.  I know the Fudgets 
library uses ^ in operators for a similar lifting meaning.


--
src/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Semantic Domain, Function, and denotational model.....

2008-09-14 Thread Daryoush Mehrtash
I have been told that for a Haskell/Functional programmer the process
of design starts with defining Semantic Domain, Function, and
denotational model of the problem.  I have done some googling on the
topic but haven't found a good reference on it.I would appreciate
any good references on the topic.

thanks,

daryoush

ps.  I have found referneces like
http://en.wikibooks.org/wiki/Haskell/Denotational_semantics  which
talks about semantic domain for the Haskell programs 10, 9+1, 2*5
which doesn't do any good for me.I need something with a more real
examples.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Semantic Domain, Function, and denotational model.....

2008-09-14 Thread Jean-Philippe Bernardy
Daryoush Mehrtash dmehrtash at gmail.com writes:

 
 I have been told that for a Haskell/Functional programmer the process
 of design starts with defining Semantic Domain, Function, and
 denotational model of the problem.  I have done some googling on the
 topic but haven't found a good reference on it.I would appreciate
 any good references on the topic.

http://www.cs.chalmers.se/Cs/Grundutb/Kurser/afp/lectures.html

The whole course is interesting but lectures 23 are more specifically about
your concern.

-- JP



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Views

2008-09-14 Thread Iavor Diatchki
Hi,

On Sun, Sep 14, 2008 at 7:01 AM, Stephan Friedrichs
[EMAIL PROTECTED] wrote:
 I agree that the MonadZero class with a useful 'zero' :: m a would be
 the right abstraction for views. But MonadZero is not part of base, mtl
 or any other common package, or am I missing something? Changing this is
 beyond a simple heap package ;)

The class ExceptionM from monadLib captures this functionality.
However, for this simple case 'Maybe' seems quite enough because it is
what you need most of the time.   Furthermore, it does not loose any
generality because you can use a function of type :: MonadZero m =
Maybe a - m a, to convert to other monads, if it is necessary.
-Iavor
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] system in forkIO

2008-09-14 Thread Marco Túlio Gontijo e Silva
Em Dom, 2008-09-14 às 11:08 -0700, Judah Jacobson escreveu:
 On Sun, Sep 14, 2008 at 10:24 AM, Marco Túlio Gontijo e Silva
 [EMAIL PROTECTED] wrote:
 
  When I run this code, I get
 
  fork
 
  and the result of ls only after I press a key.  Does getChar blocks the
  other threads?
 
 
 I think this behavior is caused by (or at least related to) the
 following GHC bug:
 
 http://hackage.haskell.org/trac/ghc/ticket/2363

Thanks, I got it to work running 

threadWaitRead stdInput

before getChar.  Only changing forkIO for forkOS gave me the same
result.

Greetings.

-- 
marcot
Página: http://marcotmarcot.iaaeee.org/
Blog: http://marcotmarcot.blogspot.com/
Correio: [EMAIL PROTECTED]
XMPP: [EMAIL PROTECTED]
IRC: [EMAIL PROTECTED]
Telefone: 25151920
Celular: 98116720
Endereço:
  Rua Turfa, 639/701
  Prado 30410-370
  Belo Horizonte/MG Brasil


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] system in forkIO

2008-09-14 Thread Jules Bean

Andrea Rossato wrote:

On Sun, Sep 14, 2008 at 02:24:23PM -0300, Marco Túlio Gontijo e Silva wrote:

and the result of ls only after I press a key.  Does getChar blocks the
other threads?


yes, but you can use forkOS from Control.Concurrent and compile with
-threaded.

See the relevant documentation for the details.


forkOS not relevant here.

-threaded is necessary to allow haskell code to run whilst FFI calls are 
blocked. getChar doesn't count as an FFI call (the RTS does its own IO 
multiplexing) but system does.


forkOS is to do with bound threads, that's something else.

Jules
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] message passing style in Monad

2008-09-14 Thread Ketil Malde
Simon Richard Clarkstone [EMAIL PROTECTED] writes:

 I can also do

   readFile readme.markdown . lines . length

 by making

(.) = flip fmap

?

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] system in forkIO

2008-09-14 Thread Marco Túlio Gontijo e Silva
Em Dom, 2008-09-14 às 16:07 -0300, Marco Túlio Gontijo e Silva escreveu:
 Thanks, I got it to work running 
 
 threadWaitRead stdInput
 
 before getChar.

Now I've got another problem:

 import Control.Concurrent
 import System.IO
 import System.Process

 main :: IO ()
 main
   = do
 process - runCommand wget
http://ftp.br.debian.org/debian/pool/main/g/ghc6/ghc6_6.8.2-6_amd64.deb;
 forkIO
   $ putStrLn fork
getChar = putChar
terminateProcess process
 waitForProcess process
 return ()

Not even fork is shown.  Any hints?

Greetings.

-- 
marcot
Página: http://marcotmarcot.iaaeee.org/
Blog: http://marcotmarcot.blogspot.com/
Correio: [EMAIL PROTECTED]
XMPP: [EMAIL PROTECTED]
IRC: [EMAIL PROTECTED]
Telefone: 25151920
Celular: 98116720
Endereço:
  Rua Turfa, 639/701
  Prado 30410-370
  Belo Horizonte/MG Brasil


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] system in forkIO

2008-09-14 Thread Don Stewart
marcot:
 Em Dom, 2008-09-14 às 16:07 -0300, Marco Túlio Gontijo e Silva escreveu:
  Thanks, I got it to work running 
  
  threadWaitRead stdInput
  
  before getChar.
 
 Now I've got another problem:
 
  import Control.Concurrent
  import System.IO
  import System.Process
 
  main :: IO ()
  main
= do
  process - runCommand wget
 http://ftp.br.debian.org/debian/pool/main/g/ghc6/ghc6_6.8.2-6_amd64.deb;
  forkIO
$ putStrLn fork
 getChar = putChar
 terminateProcess process
  waitForProcess process
  return ()
 
 Not even fork is shown.  Any hints?

Daemonic threads. When the main thread exits, everything exits. Check
the docs for Control.Concurrent.

You better use an MVar to ensure the main thread waits on its child.

-- Don
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ask

2008-09-14 Thread Jeremy Shaw
Hello,

If we look at these two examples, it appears that the results are reversed:

Prelude let n o = (-1 `o` 1) in n (-)
0
Prelude let n o = (-1 `o` 1) in n (+)
-2
Prelude 

we expect (-1 - 1) = -2 and (-1 + 1) = 0, but we get the opposite.

Due to operator precedence, the equations are being interpreted as:

Prelude let n o = (-(1 `o` 1)) in n (-)
0
Prelude let n o = (-(1 `o` 1)) in n (+)
-2

The fix is to use parens around a negative term:

Prelude let n o = ((-1) `o` 1) in n (-)
-2
Prelude let n o = ((-1) `o` 1) in n (+)
0
Prelude 

I have heard complaints about the negation sign in Haskell before, I
suppose this is why. Hopefully someone else can provide more details.

j.

ps. You could probably also fix it by changing the precedence of the
`o` operator. I believe that is possible. But parens around (-b) is
the more standard solution.

At Mon, 15 Sep 2008 02:24:14 +0200,
Cetin Sert wrote:
 
 Hi why do I get?
 
 [EMAIL PROTECTED]:~/lab/exp/1 ./eq
 23
 23
 3
 a = b = c = n1-0.8457820374040622n2-0.1542179625959377
 
 when I run
 
 import System.IO
 
 main :: IO ()
 main = do
   a ← ask a
   b ← ask b
   c ← ask c
   eval a b c
 
 ask v = do
   putStr (v ++  = )
   readLn
 
 eval a b c = do
   case delta  0 of
 True  → putStr neg
 False → putStr (n1 ++ show n1 ++ n2 ++ show n2)
   where
 delta = b*b - 4*c*a
 n  o  = (-b `o` sqrt(delta))/(2*a)
 n1= n (+)
 n2= n (-)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ask

2008-09-14 Thread Daniel Fischer
Am Montag, 15. September 2008 02:24 schrieb Cetin Sert:
 Hi why do I get?

Buffering. For compiled programmes, stdin and stdout are line-buffered by 
default, so the output doesn't appear until the program finishes.
Either put
hSetBuffering stdout NoBuffering
at the top of main or, better IMO,
insert a 
hFlush stdout
into ask before the readLn.
And in eval, putStrLn would be better, I think.

HTH,
Daniel

 [EMAIL PROTECTED]:~/lab/exp/1 ./eq
 23
 23
 3
 a = b = c = n1-0.8457820374040622n2-0.1542179625959377

 when I run

 import System.IO

 main :: IO ()
 main = do
   a ← ask a
   b ← ask b
   c ← ask c
   eval a b c

 ask v = do
   putStr (v ++  = )
   readLn

 eval a b c = do
   case delta  0 of
 True  → putStr neg
 False → putStr (n1 ++ show n1 ++ n2 ++ show n2)
   where
 delta = b*b - 4*c*a
 n  o  = (-b `o` sqrt(delta))/(2*a)
 n1= n (+)
 n2= n (-)

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ask

2008-09-14 Thread Brandon S. Allbery KF8NH

On 2008 Sep 14, at 20:47, Brandon S. Allbery KF8NH wrote:

On 2008 Sep 14, at 20:24, Cetin Sert wrote:

Hi why do I get?

[EMAIL PROTECTED]:~/lab/exp/1 ./eq
23
23
3
a = b = c = n1-0.8457820374040622n2-0.1542179625959377


As is typical for Unix, filehandles including standard input and  
standard output are line buffered.  See hSetBuffering ( http://www.haskell.org/ghc/docs/latest/html/libraries/base/System-IO.html#v%3AhSetBuffering 
 ).


Also, looking at that path, I'm tempted to point you to http://www.haskell.org/haskellwiki/Homework_help 
 .


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hugs on the iphone

2008-09-14 Thread Miguel Mitrofanov
As pie. Just downloaded the source and compiled it on iPhone itself  
(no cross-compiling).


On 15 Sep 2008, at 09:25, Don Stewart wrote:


Very nice. Easy?

miguelimo38:


Did that.
http://migmit.vox.com/library/photo/6a00e398c5c26f000500fa9696d8c40002.html

On 14 Sep 2008, at 14:17, Alberto R. Galdo wrote:


Hi, is there any chance of having hugs  compile for the iPhone?

Cross-compiling? Compiling directly on the iPhone?

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hugs on the iphone

2008-09-14 Thread Don Stewart
Very nice. Easy?

miguelimo38:

 Did that. 
 http://migmit.vox.com/library/photo/6a00e398c5c26f000500fa9696d8c40002.html
 
 On 14 Sep 2008, at 14:17, Alberto R. Galdo wrote:
 
 Hi, is there any chance of having hugs  compile for the iPhone?
 
 Cross-compiling? Compiling directly on the iPhone?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hugs on the iphone

2008-09-14 Thread Miguel Mitrofanov

Did that. 
http://migmit.vox.com/library/photo/6a00e398c5c26f000500fa9696d8c40002.html

On 14 Sep 2008, at 14:17, Alberto R. Galdo wrote:


Hi, is there any chance of having hugs  compile for the iPhone?

Cross-compiling? Compiling directly on the iPhone?

Greets,
Alberto
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ask

2008-09-14 Thread Cetin Sert
Hi why do I get?

[EMAIL PROTECTED]:~/lab/exp/1 ./eq
23
23
3
a = b = c = n1-0.8457820374040622n2-0.1542179625959377

when I run

import System.IO

main :: IO ()
main = do
  a ← ask a
  b ← ask b
  c ← ask c
  eval a b c

ask v = do
  putStr (v ++  = )
  readLn

eval a b c = do
  case delta  0 of
True  → putStr neg
False → putStr (n1 ++ show n1 ++ n2 ++ show n2)
  where
delta = b*b - 4*c*a
n  o  = (-b `o` sqrt(delta))/(2*a)
n1= n (+)
n2= n (-)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] system in forkIO

2008-09-14 Thread Marco Túlio Gontijo e Silva
Em Dom, 2008-09-14 às 14:52 -0700, Don Stewart escreveu:
 marcot:
  Em Dom, 2008-09-14 às 16:07 -0300, Marco Túlio Gontijo e Silva escreveu:
   Thanks, I got it to work running 
   
   threadWaitRead stdInput
   
   before getChar.
  
  Now I've got another problem:
  
   import Control.Concurrent
   import System.IO
   import System.Process
  
   main :: IO ()
   main
 = do
   process - runCommand wget
  http://ftp.br.debian.org/debian/pool/main/g/ghc6/ghc6_6.8.2-6_amd64.deb;
   forkIO
 $ putStrLn fork
  getChar = putChar
  terminateProcess process
   waitForProcess process
   return ()
  
  Not even fork is shown.  Any hints?
 
 Daemonic threads. When the main thread exits, everything exits. Check
 the docs for Control.Concurrent.
 
 You better use an MVar to ensure the main thread waits on its child.

I don't think this is the problem because the mais thread is not
exiting.  wget takes a lot of time to end, and I never really wait it to
finish.  I wanted to enable the user to interrupt it, but if it's
finished, I don't want to wait for the user input anymore, so the child
thread can exit with the main one.

I just noticed that if I add a putStrLn wait before waitForProcess,
it'll print wait and then fork.  I couldn't understand why this
happened, but I can't still pass through getChar to get to
terminateProcess.

Is it right to call getChar inside a forkIO?

Greetings.

-- 
marcot
Página: http://marcotmarcot.iaaeee.org/
Blog: http://marcotmarcot.blogspot.com/
Correio: [EMAIL PROTECTED]
XMPP: [EMAIL PROTECTED]
IRC: [EMAIL PROTECTED]
Telefone: 25151920
Celular: 98116720
Endereço:
  Rua Turfa, 639/701
  Prado 30410-370
  Belo Horizonte/MG Brasil


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ask

2008-09-14 Thread Brandon S. Allbery KF8NH

On 2008 Sep 14, at 20:24, Cetin Sert wrote:

Hi why do I get?

[EMAIL PROTECTED]:~/lab/exp/1 ./eq
23
23
3
a = b = c = n1-0.8457820374040622n2-0.1542179625959377


As is typical for Unix, filehandles including standard input and  
standard output are line buffered.  See hSetBuffering ( http://www.haskell.org/ghc/docs/latest/html/libraries/base/System-IO.html#v%3AhSetBuffering 
 ).


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ask

2008-09-14 Thread Richard A. O'Keefe


On 15 Sep 2008, at 12:51 pm, Daniel Fischer wrote:


Am Montag, 15. September 2008 02:24 schrieb Cetin Sert:

Hi why do I get?


Buffering. For compiled programmes, stdin and stdout are line- 
buffered by

default, so the output doesn't appear until the program finishes.
Either put
hSetBuffering stdout NoBuffering
at the top of main or, better IMO,
insert a
hFlush stdout
into ask before the readLn.
And in eval, putStrLn would be better, I think.


Is this the problem we've had before, where the example in the
Haskell 98 Report could not possibly work unless Haskell followed
the same rule as C (read from stdin *automatically* flushes stdout),
and the example works in several other Haskell systems, but not in
GHC?  Or is this a different problem?

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hugs on the iphone

2008-09-14 Thread Alberto R. Galdo

Cool! That's such a proof that it can be done...

I had lots of problems trying to cross compile hugs from my mac to arm  
architecture ( seems that hugs codebase is not capable of cross  
compiling )


And when compiling directly  on the iPhone, first there where problems  
with code signing, now with the configure script and C preprocessor  
sanity check...


Any light on the topic from your experience?

On 15/09/2008, at 7:24, Miguel Mitrofanov [EMAIL PROTECTED] wrote:


Did that. 
http://migmit.vox.com/library/photo/6a00e398c5c26f000500fa9696d8c40002.html

On 14 Sep 2008, at 14:17, Alberto R. Galdo wrote:


Hi, is there any chance of having hugs  compile for the iPhone?

Cross-compiling? Compiling directly on the iPhone?

Greets,
Alberto
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe