[Haskell-cafe] what is a difference between existential quantification and polymorhic field?

2006-09-21 Thread Bulat Ziganshin
Hello haskell-cafe,

now i'm reading Haskell' proposals and found that these two things
considered as different:

http://hackage.haskell.org/trac/haskell-prime/wiki/ExistentialQuantification
http://hackage.haskell.org/trac/haskell-prime/wiki/PolymorphicComponents

can you please explain me what is the difference between

data Ex = forall a. Num a =  Ex a

and

data Po = Po (forall a. Num a = a)

?

-- 
Best regards,
 Bulat  mailto:[EMAIL PROTECTED]

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


[Haskell-cafe] Re: Haskell web forum

2006-09-21 Thread Albert Lai
As requested, I continue here the thread on the proposal for a web forum.

You will soon enough find out what I think of web forums.  Let me
first show you what this mailing list looks like to me using software
of my choice:

!  [ 192: Mark Carroll] [Haskell-cafe] Card trick
!  [  37: Thomas Conway   ] Re: [Haskell-cafe] How can we detect and fix
E  [  19: Albert Lai  ] Re: [Haskell-cafe] Either e Monad
E  [  19: Deokhwan Kim]
   [  62: Bas van Dijk]
E  [  47: [EMAIL PROTECTED] [Haskell-cafe] Re: Optimization problem
   [  51: Ross Paterson   ]
E  [  42: Conor McBride   ]
   [  56: Robert Dockins  ]
   [  42: Conor McBride   ]
   [  61: [EMAIL PROTECTED] [Haskell-cafe] Re:  Optimization prob
   [  14: Ross Paterson   ]
   [ 154: Jan-Willem Maessen  ] Re: [Haskell-cafe] Traversing a graph in STM
   [  52: Josef Svenningsson  ]
   [  18: Bulat Ziganshin ] Re[2]: [Haskell-cafe] Traversing a graph 
   [  26: Sebastian Sylvan]
   [  22: Ashley Yakeley  ] [Haskell-cafe] Re: Wiki contact

An elaboration of the cool features I have always enjoyed is in order:

On browsing threads, both inter-thread jumps and intra-thread
navigation, the screenshot speaks for itself.  (If for any perverted
reason I want the messages listed chronologically rather than
well-organized, the software can do it too.)

The messages marked with E are messages I have just read.  With this
mark, they will not show up next time I browse this mailing list
again.  Take note that I can mark and unmark any subset of messages,
unlike certain people's linear-time idea that one single timestamp
distinguishes already read from new across the board.  (I have
always heard that non-linear thinking is superior to linear thinking.
I think I believe it for at least this application.)  (Is this an
example of what is meant when someone said that a web forum requires
less technical knowledge, i.e., programmers on a web forum will not
need to know about subsets?)  (Speaking of which, is the
thread-browsing part also an example, i.e., programmers on a web forum
will not need to know about trees and forests?)

Though the marked messages will not show up next time, they are not
thrown away yet.  They are kept on my disk for quite a while.  (I get
to set how many days they stay.)  The software offers several ways to
show them, but I think the most useful one is this.  Suppose I look at
apfelmus's message on Optimization problem (two are shown, I'm
referring to the first one), and wonder, gee, what is it replying
to?  To find out, I position myself to that message, then press a
button, then the software will show the desired parent message.  In
fact, the updated screen looks like this (I just include the thread in
question):

E  [  18: Ross Paterson   ] Re: [Haskell-cafe] Re: Optimization problem
E  [  47: [EMAIL PROTECTED]
   [  51: Ross Paterson   ]
E  [  42: Conor McBride   ]
   [  56: Robert Dockins  ]
   [  42: Conor McBride   ]
   [  61: [EMAIL PROTECTED] [Haskell-cafe] Re:  Optimizatio
   [  14: Ross Paterson   ]

So even if apfelmus's message quotes nothing from Ross's, I can still
find out, provided it is recently enough to be still on my disk.  Take
note that, on a linear-thinking web forum, there could be any number
of intervening messages in the same thread between Ross's and
apfelmus's, and even though it is true that Ross's is immortalized in
the database of the forum, the real question is how to fish for it.
(ObRant again about how web forums are friendly to programmers who
have no clue about trees.)

Here is a feature unrelated to threading, and in fact it is much more
fundamental and pervasive (since almost all email software, not just
mine, provides this), and in fact it has much to do with pervasive
computing too.  Here in Canada, in cafes one can get wireless Internet
access, but it has to be paid by the minutes.  So suppose I want to
visit haskell-cafe when I visit a Starbucks cafe, and there are 30
messages I want to read, and I can read them at the rate of half a
minute per message.  If haskell-cafe were on a web forum, I would end
up keeping my wireless connection for 15 minutes.  (Could I disconnect
and reconnect between messages?  First of all that's really a pain.
Secondly, let's say I do that, the billing is still such that I
connect for 2 seconds and I'm still charged for 1 minute.)  But since
haskell-cafe is on a mailing list, I can just connect for a few
seconds to download the messages, then disconnect and read offline;
I'm charged for at most 1 minute.

(Alternatively but equivalently, suppose I want to read haskell-cafe
while riding subway - underground trains.  Here in Toronto the subway
doesn't provide wireless Internet access yet, and probably won't for
another decade.  If haskell-cafe 

Re: [Haskell-cafe] what is a difference between existential quantification and polymorhic field?

2006-09-21 Thread Ross Paterson
[apologies to Bulat for the repeat posting]

On Thu, Sep 21, 2006 at 12:05:23PM +0400, Bulat Ziganshin wrote:
 now i'm reading Haskell' proposals and found that these two things
 considered as different:
 
 http://hackage.haskell.org/trac/haskell-prime/wiki/ExistentialQuantification
 http://hackage.haskell.org/trac/haskell-prime/wiki/PolymorphicComponents
 
 can you please explain me what is the difference between
 
 data Ex = forall a. Num a =  Ex a
 
 and
 
 data Po = Po (forall a. Num a = a)

Consider the types of the constructors:

Ex :: forall a. (Num a) = a - Ex
Po :: (forall a. (Num a) = a) - Po

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


Re: [Haskell-cafe] [newbie] How to test this function?

2006-09-21 Thread Bulat Ziganshin
Hello Bruno,

Thursday, September 21, 2006, 8:28:23 AM, you wrote:

 First, how do I fix the identation of the if then else?

http://haskell.org/haskellwiki/IO_inside contains a lot of information
about using IO monad

 Second, I want to test this function, without hitting the filesystem.  In
 C++ I would use a istringstream.  I couldn't find a function that returns
 a Handle from a String.

http://haskell.org/haskellwiki/Library/Streams

although you will need to slightly change your program using v*
operations instead of h*, in return you will get ability to use String
as Stream:

h1 - openFile test ReadMode
vGetChar h1
h2 - newStringReader input
vGetChar h2



-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Trouble with simple embedding of shell in haskell

2006-09-21 Thread Bulat Ziganshin
Hello George,

Thursday, September 21, 2006, 7:44:22 AM, you wrote:

 sh :: String - String - IO String
 sh cmd = \input - 
  do (stdin, stdout, _, pid) - runInteractiveCommand cmd
 forkIO $ hPutStr stdin input  hClose stdin
 -- get exit status to prevent zombie accumulation
 forkIO $ waitForProcess pid  return ()
 hGetContents stdout

1. when 'main' finishes, all the threads created by forkIO, silently
dies. typically you need to wait until they are finished. ghc
libraries don't provide any provision for it, they are too low-level.
you can consider writing your own simple wrapper using MVar:

myFork action = do
  v - newEmptyMVar
  forIO $ action = putMVar v
  return v

finishHim v = takeMVar v

which also returns value returned by action. usage:

subProcess - myFork $ do-something-here
...
finishHim subProcess


or you can use some simple libraries which use more developed
solutions of this problem:
http://freearc.narod.ru/Process.tar.gz (my own)
http://www-i2.informatik.rwth-aachen.de/~stolz/Haskell/CA.hs



2. afaiu, you don't want to wait for process finishing before calling
getContents? in this case you need to collect all 'pids' returned by
myFork function in some list and finish them all before main returns.
or, better, develop more complex interface that will allow to kill
processes whose output is no more required, in order to help
'head'-like processes




also look at
http://www.haskell.org/~petersen/haskell/popenhs/popenhs-1.00.0.tar.gz
http://www.volker-wysk.de/hsshellscript/dist/hsshellscript-2.5.0.tar.gz
and file i attached


also, look at Tackling the awkward squad: monadic input/output,
concurrency, exceptions, and foreign-language calls in Haskell
http://research.microsoft.com/Users/simonpj/papers/marktoberdorf/marktoberdorf.ps.gz
paper, which is a definitive source of information about GHC
concurrency implementation


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]Following the release early, release often motto, I am happy to
announce version 0.1.0 of HSH, the Haskell shell.

You may obtain it with:

darcs get --tag 0.1.0 http://darcs.complete.org/hsh

Things are still very rough in many ways, but this version already lets
you:

 * Run commands

 * Pipe things between commands

 * Pipe command input/output into and out of pure Haskell functions

 * Pure Haskell functions are as much a first-class citizen as
   is grep or cat

Here is an example session:

$ ghci -fglasgow-exts HSH

*HSH run $ (ls, [.])
COPYINGHSHHSH.hsTODOannouncements  testsrc
COPYRIGHT  HSH.cabal  Makefile  _darcs  test.hs

*HSH run $ (ls, [-l]) -|- (wc, [-l])
12

*HSH :m +Text.Printf
*HSH Text.Printf let countLines = (zipWith (\i line - printf %-5d %s i 
line) [(1::Int)..])::([String] - [String])

*HSH Text.Printf run $ (ls, [-l]) -|- countLines -|- (grep, [hs$])
6 -rw-r--r-- 1 jgoerzen jgoerzen  1285 Jun  6 09:43 HSH.hs
11-rw-r--r-- 1 jgoerzen jgoerzen   565 Jun  6 09:43 test.hs

*HSH Text.Printf :m +Data.List
*HSH Text.Printf Data.List run $ (ls, [-l]) -|- countLines -|- filter 
(isSuffixOf hs)
6 -rw-r--r-- 1 jgoerzen jgoerzen  1285 Jun  6 09:43 HSH.hs
11-rw-r--r-- 1 jgoerzen jgoerzen   565 Jun  6 09:43 test.hs

*HSH Text.Printf Data.List run $ (ls, [-l]) -|- countLines -|- filter 
(isSuffixOf hs) -|- (tr, [a-z, A-Z])
6 -RW-R--R-- 1 JGOERZEN JGOERZEN  1285 JUN  6 09:43 HSH.HS
11-RW-R--R-- 1 JGOERZEN JGOERZEN   565 JUN  6 09:43 TEST.HS

*HSH Text.Printf Data.List let generator = \(_::String) - unlines . map show 
$ [1..20]
*HSH Text.Printf Data.List generator 
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n
*HSH Text.Printf Data.List run $ generator -|- (grep, [1])
1
10
11
12
13
14
15
16
17
18
19

Future versions will likely simplify syntax to make it easier to write scripts
and introduce a sh to hsh converter.  I also plan to add pure Haskell
tools for some common shell-ish things that one could do in Haskell.

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


Re[2]: [Haskell-cafe] what is a difference between existential quantification and polymorhic field?

2006-09-21 Thread Bulat Ziganshin
Hello Ross,

Thursday, September 21, 2006, 12:55:40 PM, you wrote:

 data Ex = forall a. Num a =  Ex a
 
 and
 
 data Po = Po (forall a. Num a = a)

 Consider the types of the constructors:

 Ex :: forall a. (Num a) = a - Ex
 Po :: (forall a. (Num a) = a) - Po

sorry, Ross, can you give me a more detailed explanation? it seems
that Po argument is existential by itself, but i don't understand that
all this mean

also, ghc66 adds impredicative polymorphism. how it differs from
unqualified existentials?


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Re: Haskell web forum

2006-09-21 Thread Gour
On Thu, 2006-09-21 at 04:55 -0400, Albert Lai wrote:

 As requested, I continue here the thread on the proposal for a web forum.
 
 You will soon enough find out what I think of web forums. 

[snip]

I don't understand one thing: it looks like web-forums should exclude
mailing lists and vice versa, but Bulat just wrote: ...we need now to
create web forum. ??

So, why the two cannot co-exist and let users decide which one to use?

Gentoo community is nice example of it.

Sincerely,
Gour



signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] what is a difference between existential quantification and polymorhic field?

2006-09-21 Thread Bruno Oliveira



Hello Bullat,



now i'm reading Haskell' proposals and found that these two things

considered as different:



http://hackage.haskell.org/trac/haskell-prime/wiki/ExistentialQuantification

http://hackage.haskell.org/trac/haskell-prime/wiki/PolymorphicComponents



can you please explain me what is the difference between



data Ex = forall a. Num a =  Ex a



and



data Po = Po (forall a. Num a = a)





With existencial types you know what what the type of the thing 

you are packing is:



 t = Ex (3 :: Int)



and you forget about it once it is packed.



However, with polymophic components the following is a type error



 t = Po ( 3 :: Int)



because you are required to provide a polymorphic value (forall a . Num a = a)

and you have given it a value Int. However, the following is valid:



 t1 = Po 3



since (3 :: forall a . Num a = a).



So, perhaps an easy way to think about existencials is that they are almost like:



 data Ex a = Ex a



except that the type "a" is lost as soon as you construct such a value. 



Where does this make a difference? 



Try the following two definitions: 



 addPo :: Po - Po - Po

 addPo (Po x) (Po y) = Po (x + y)



 addEx :: Ex - Ex - Ex

 addEx (Ex x) (Ex y) = Ex (x + y)



The first one works, the second one doesn't. The reason that the first works is because "x" and "y" 

are polymorphic and thus they can be unified. This is more/less equivallent to:



 addPo' :: (forall a . Num a = a) - (forall a . Num a = a) - (forall a . Num a = a)

 addPo' x y = x + y



The second does *not* work because when you created the values for the existencials you assumed 

some concrete types. So, "x" could be an Integer and "y" could be a Float and therefore, you should 

not be allowed to perform this operation.



 also, ghc66 adds impredicative polymorphism. how it differs from

 unqualified existentials?



I have not tried ghc66, but I think one of the things you should be able to do and that 

is perhaps helpful for understanding existencial is:



 myList :: [forall a . Num a = a]

 myList = [3 :: Int, 4 :: Float, 6 :: Integer]



which in previous versions of GHC would need to be written as:



 myList :: [Ex]

 myList = [Ex (3 ::Int), Ex (4 :: Float), Ex (6 :: Integer)]



Hope this helps.



Cheers,



Bruno Oliveira




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


Re: [Haskell-cafe] Re: Haskell web forum

2006-09-21 Thread Kurt Hutchinson

On 9/21/06, Gour [EMAIL PROTECTED] wrote:

So, why the two cannot co-exist and let users decide which one to use?

Gentoo community is nice example of it.


I was just about to ask the same thing. Clearly, some prefer email and
some prefer web forums. This is undoubtably true of new Haskell users
with questions, as well. Let those interested in a web forum set one
up and run it. Those interested in email can ignore the web forum. The
Perl community has a similar setup with the popular Perlmonks web
forum, and their hundreds of mailing lists. There are many users who
read and post on both, and many who do not.

I believe Bulat was just trying to find out if anyone else would like
to help set one up, not suggesting that it replace the mailing lists.

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


Re: [Haskell-cafe] Re: Haskell web forum

2006-09-21 Thread Bill Wood
I have only recently started accessing some web fora, but I've noticed
that some of those powered by phpBB are vulnerable to spamming,
whereas the news groups seem to be less so.  For example, the
python-forum has nearly lost it's General forum to spammers.  Maybe
the experts know better engines, better ways to set up a forum, or
better ways to administer them after they're up, but it is a concern.

 -- Bill Wood



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


Re: [Haskell-cafe] Re: Haskell web forum

2006-09-21 Thread Alex Queiroz

Hallo,

On 9/21/06, Bill Wood [EMAIL PROTECTED] wrote:

I have only recently started accessing some web fora, but I've noticed
that some of those powered by phpBB are vulnerable to spamming,
whereas the news groups seem to be less so.  For example, the
python-forum has nearly lost it's General forum to spammers.  Maybe
the experts know better engines, better ways to set up a forum, or
better ways to administer them after they're up, but it is a concern.



I only hope this mailing list will continue. I can't stand the
slowness/spams/avatar/size of web fora.

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


Re: [Haskell-cafe] Re: Haskell web forum

2006-09-21 Thread Misha Aizatulin
Kurt Hutchinson wrote:

 Let those interested in a web forum set one
 up and run it. Those interested in email can ignore the web forum.

  My concern about introducing a web forum would be that it is yet
another place I have to search every time I need information (besides
the haskell report, compiler docs and tracker, 2 wikis and the mailing
lists :)

  So setting up a web forum would only be good if it can do something a
mailing list cannot do. Following things were mentioned before:

- ease of starting new topics. Maybe. I personally end up searching
through all topics in forums anyway, because people often tend to post
in a wrong topic :) Christian Neumann before mentioned that mailman
might support topics as well.
  Also IMHO the current division of mailing lists (general, café,
libraries, etc.) is exactly right for organizing and separating information.

- searchability. I wouldn't agree - I can download the whole contents of
a mailing list from gmane and search it in my mail client - goes way
faster than in a forum.

- ease of access. But preventing spam would probably require
subscription just as for a mailing list.

  Any more advantages of a forum?

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


Re: [Haskell-cafe] what is a difference between existential quantification and polymorhic field?

2006-09-21 Thread Bruno Oliveira
Hello Bullat,

 also, ghc66 adds impredicative polymorphism. how it differs from
 unqualified existentials?

 I have not tried ghc66, but I think one of the things you should be able to 
 do and that 
 is perhaps helpful for understanding existencial is:
 
  myList :: [forall a . Num a = a]
  myList = [3 :: Int, 4 :: Float, 6 :: Integer]

 which in previous versions of GHC would need to be written as:

  myList :: [Ex]
  myList = [Ex (3 ::Int), Ex (4 :: Float), Ex (6 :: Integer)]

I took a look at the documentation and I think I told you the wrong thing here.
I think this should be equivallent to:

 myList :: [Po]
 myList = [Po 3, Po 4, Po 6]

which, in this case wouldn't be too useful (would it?). Having structures with 
polymorphic 
components is more useful when you have functions. The example they give is:

 f :: Maybe (forall a. [a] - [a]) - Maybe ([Int], [Char])
  f (Just g) = Just (g [3], g hello)
  f Nothing  = Nothing

However, the following (which would be the right way to express my example) 
would be handy to have as well:

 myList :: [exists a . Num a = a]
 myList = [3 :: Int, 4 :: Float, 6 :: Integer]

but I don't think this is available in GHC 6.6.

Can anyone confirm this?

Cheers,

Bruno Oliveira




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


[Haskell-cafe] Re: [newbie] How to test this function?

2006-09-21 Thread Bruno Martínez
On Thu, 21 Sep 2006 01:52:38 -0300, Donald Bruce Stewart  
[EMAIL PROTECTED] wrote:



First, how do I fix the identation of the if then else?

getList = find 5
where find 0 = return []
  find n = do
ch - getChar
if ch `elem` ['a'..'e']
then do tl - find (n-1)
return (ch : tl)
else find n


OK.  Thanks.  I didn't find that one because it's not offered as an  
identation option in emacs haskell mode.


Second, I want to test this function, without hitting the filesystem.   
In
C++ I would use a istringstream.  I couldn't find a function that  
returns
a Handle from a String.  The closer thing that may work that I could  
find
was making a pipe and convertind the file descriptor.  Can I simplify  
that

function to take it out of the IO monad?  How?  I thought about
getContents, but that eats all input.


Refactor!
The reason your getList is hard to test, is that you're mixing side
effecting monadic code with pure computations. Let's untangle that, and
then test the the referentially transparent parts simply with
QuickCheck. And remember that since getContents uses lazy IO, it only
eats as much input as you ask it to.

So let's refactor this, partitioning off the side effecting IO code:

getList :: IO [Char]
getList = take5 `fmap` getContents -- a thin IO skin

take5 :: [Char] - [Char]
take5 = take 5 . filter (`elem` ['a'..'e']) -- the actual worker


The problem is that getContents 'eats' stdin, which can't be used again.   
I'm forced to change all my IO code to the getContents way, which is not  
possible.


About QuickCheck: I'm going to check it out.  Thanks for the pointers.

Bruno

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


[Haskell-cafe] Re: Re: [newbie] How to test this function?

2006-09-21 Thread Bruno Martínez
On Thu, 21 Sep 2006 11:20:33 -0300, Henning Thielemann  
[EMAIL PROTECTED] wrote:




On Thu, 21 Sep 2006, Bruno Martínez wrote:


 getList :: IO [Char]
 getList = take5 `fmap` getContents -- a thin IO skin

 take5 :: [Char] - [Char]
 take5 = take 5 . filter (`elem` ['a'..'e']) -- the actual worker

The problem is that getContents 'eats' stdin, which can't be used again.


You can process the result of getContents as many times as you want.


But I cannot process input again without getContents.  This function's use  
of getContents forces me to use only getContents everywhere.  For example,  
I can't use hWaitForInput in another IO action.



I'm forced to change all my IO code to the getContents way, which is not
possible.


If your program contains so much IO code you should seriously consider
refactoring.


I try to minimize the amount of IO I do, but there's a point I don't know  
how to strip my functions of their remaining IOness.  That's why I ask :)


Bruno

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


Re: [Haskell-cafe] [newbie] How to test this function?

2006-09-21 Thread Bruno Martínez

On Thu, 21 Sep 2006 05:30:34 -0300, Bulat Ziganshin
[EMAIL PROTECTED] wrote:


Hello Bruno,

Thursday, September 21, 2006, 8:28:23 AM, you wrote:


First, how do I fix the identation of the if then else?


http://haskell.org/haskellwiki/IO_inside contains a lot of information
about using IO monad


That page is very good.

Second, I want to test this function, without hitting the filesystem.   
In
C++ I would use a istringstream.  I couldn't find a function that  
returns

a Handle from a String.


http://haskell.org/haskellwiki/Library/Streams


I'll give this a try.

Thanks,
Bruno

Conectese mas rapido y ahorre hasta un 50%
   Tel. 0909.2030 =  $0,15 IVA incluido el minuto
__
http://www.internet.com.uy - En Uruguay somos internet

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


Re: [Haskell-cafe] Re: Haskell web forum

2006-09-21 Thread David House

On 21/09/06, Misha Aizatulin [EMAIL PROTECTED] wrote:

  My concern about introducing a web forum would be that it is yet
another place I have to search every time I need information (besides
the haskell report, compiler docs and tracker, 2 wikis and the mailing
lists :)


So let's have a single unified search box. This is what was done on
wordpress.org -- a single glorified interface searched the wiki,
support forums and bug tracker. Everything's currently hosted by the
umbrella domain name haskell.org, so all the information's at least
theoretically in the same place, so getting the various tools
interoperating with one another shouldn't be impossible.

+1 for the introduction of forums.

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


[Haskell-cafe] Non-existant existential?

2006-09-21 Thread Jim Apple

Consider the following:

data SimpExist a = SimpExist (forall x . x - a)
f :: SimpExist Bool
f = SimpExist (const True)
g = SimpExist id

What is the type of g? In a similar example, GHC tells me it is of
type SimpExist c. Yet, I can't unify it with any other SimpExist c'.

It seems to me that this is something like exists x . SimpExist x, and
is similar to:

data ExistWrap = forall a . ExistWrap (forall x . x - a)

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


Re: [Haskell-cafe] Re: Trying to write a TCP proxy

2006-09-21 Thread David House

On 20/09/06, John Ky [EMAIL PROTECTED] wrote:

So Monads don't actually eliminate laziness?


Monads and laziness are completely orthagonal issues; they have
nothing to do with one another. I think you're getting confused with
purity. Monads can be used to encapsulate effects, to allow you to
write code as if the code had side effects, while your program remains
technically pure.

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


Re: [Haskell-cafe] Re: Haskell web forum

2006-09-21 Thread Kurt Hutchinson

On 9/21/06, Misha Aizatulin [EMAIL PROTECTED] wrote:

  My concern about introducing a web forum would be that it is yet
another place I have to search every time I need information (besides
the haskell report, compiler docs and tracker, 2 wikis and the mailing
lists :)


That probably speaks to an effort for better organization of the
information rather than banning a way to create more.


  So setting up a web forum would only be good if it can do something a
mailing list cannot do.


Well there's one thing that a web forum can do that a mailing list can
never do, which is provide a mechanism for those who like web forums
better than mailing lists. How important that is really depends on how
many people would rather use a web forum than a mailing list. Many of
the responses so far have decried web forums in preference to mailing
lists, but this is, after all, a mailing list.


- searchability. I wouldn't agree - I can download the whole contents of
a mailing list from gmane and search it in my mail client - goes way
faster than in a forum.


A similar mechanism could be implemented for a web forum. The data is
just sitting in a database, after all. An format for easy downloading
and searching would probably not be difficult.

I personally don't care either way. I'm happy with the mailing list.
But I know of many people that do prefer web forums, and they seem to
be perceived as a lower barrier to entry, even if that isn't actually
true. I would probably read both if both existed.

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


Re: [Haskell-cafe] Non-existant existential?

2006-09-21 Thread Bruno Oliveira
Hello,

Consider the following:

data SimpExist a = SimpExist (forall x . x - a)
f :: SimpExist Bool
f = SimpExist (const True)
g = SimpExist id

What is the type of g? In a similar example, GHC tells me it is of
type SimpExist c. Yet, I can't unify it with any other SimpExist c'.

Have you tried to type check this example (the g)?

It does not type check in my GHC. There are not many functions with 
the type forall x . x - a when a is also polymorphic --- it is the type of 
 unsafeCoerce.

It seems to me that this is something like exists x . SimpExist x, and
is similar to:

data ExistWrap = forall a . ExistWrap (forall x . x - a)

Sure, you should read a forall on the left side of a constructor as 
exists. 

Look at section 7.4.1.4.1 of:

http://www.haskell.org/ghc/docs/6.4.2/html/users_guide/type-extensions.html

The design decision here was to avoid introducing a new exist construct. I 
believe 
that the justification for this option is that in Logic a forall in a 
contravariant position 
has the same effect as an existential.

Cheers,

Bruno


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


[Haskell-cafe] Re: Haskell web forum

2006-09-21 Thread Aaron Denney
Moved to haskell-cafe from haskell-general.
On 2006-09-20, Niklas Broberg [EMAIL PROTECTED] wrote:
 On 9/20/06, Aaron Denney [EMAIL PROTECTED] wrote:
 And I disagree with you.  Web forums are usenet reinvented poorly.
 It's impossible to keep track of what's new, threading is either poor or
 nonexistent.  Mailing lists with searchable archives work well.  gmane
 provides a nice usenet interface to mailing lists.

 I don't recognize the forums I frequent in your description at all. I
 have absolutely no problem keeping up with what's new. In fact I find
 it a lot easier since many of the topics take place in subforums that
 I know don't interest me, so I don't even need to go there to check.

And half of the time messages are miscategorized, because conversations
are miscategorized, so I do need to go check.

 With this mailing list, I have to manually mark as read about 2/3 of
 all incoming mails because they don't (from the title) interest me,
 and I have to read a few that don't interest me because I couldn't
 tell from the title.

Where as an entire page of messages under a particular thread (it's
not a thread, because they almost never have the messages showing the
exact post they're responding to, just the general list of messages
in this topic.)  Then I need to go locate the tiny link that gets me to
the next page.  They're nearly unuseable.

 Threading also works as well as could be expected, better than
 threading in gmail for instance, so I don't see the problem here
 either.

That has never been my experience.  Threads branch annd mutate and
drift.  And this is a good thing.  The rigid categorizations can't
handle this, whereas I can easily ignore entire threads and subthreads
with a client designed for it.

  It's all there, all the time.

 Yes, that's part of the problem.

 How is that? You mean because all the old stuff gets in the way of the
 new? Then you're just using a bad forum software that can't properly
 point out the new stuff for you. I agree that not all forums are good,
 but there are definitely those that are.

Exactly.  but the problem with forums is that everynone must use the
same forum software because it's sitting on a website.   With usenet or
mailing lists, everyone gets their own software that provides the
features they want, with the interface they want.

  It is also  easy to create sub-groups/forums for specific projects,

 This is the one semi-useful thing.  Of course, what you end up with is
 another not-so-useful forum.

 This is probably the one most useful thing yes. I wouldn't call it
 semi-useful though. Just remember all the responses that the HCAR gets
 each year of the form wow how many cool projects are out there that I
 had no clue existed. What if all (or many of) those projects were
 actually there, on the forums, where everyone knew where to look?

Forums are another place to look, instead of on the wiki, on the mailing
lists, etc.  It fragments the community.

 And your last sentence, I just don't understand. not-so-useful just
 because it's a forum, or did you mean somethine else as well?

Yes, because it's a forum.

Almost any feature can be implemented in a web-forum.  And many will,
but almost none will be done well, because
(a) it's hard to get something that will please everyone  and it has to
please everyone because everyone must use the same software
(b) The experience isn't there.  Mail  usenet software has been
worked on for over 25 years.  It works.  Your mail client sucks? 
Get a new one.  There are lots, and one should surely work for you.
I don't have the option of using different web-forum software when
something about it annoys the hell out of me.

The biggest thing I see for them is web accessibility.  But we already
have that.  We have archives.  We have gmane.  Tons of other gatewaying
software exist, and could be easily set up, because mailing lists are
designed to be used by multiple clients.

Web forums are only pull.  I have to go check each individual one,
on a semi-regular basis.  Yes, there is RSS.  It's another hacky
workaround for something that mail inherently has.  Mailiing lists can
be either pull or push.  I can dump the list mail in my inbox and get it
regularly, or segregate it out to another mailbox, or several mailboxes,
or whatever.

-- 
Aaron Denney
--

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


[Haskell-cafe] Re: [newbie] How to test this function?

2006-09-21 Thread Benjamin Franksen
Bruno Martínez wrote:
 On Thu, 21 Sep 2006 01:52:38 -0300, Donald Bruce Stewart
 [EMAIL PROTECTED] wrote:
 
 First, how do I fix the identation of the if then else?
 getList = find 5
 where find 0 = return []
   find n = do
 ch - getChar
 if ch `elem` ['a'..'e']
 then do tl - find (n-1)
 return (ch : tl)
 else find n
 
 OK.  Thanks.  I didn't find that one because it's not offered as an
 identation option in emacs haskell mode.

Emacs is evil!

It also inserts random tab characters into your code just to save a few
space bytes. Tends to completely trash indentation e.g. when pasting code
into mails etc.

Ben

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


[Haskell-cafe] Re: Re: Haskell web forum

2006-09-21 Thread Rene de Visser
I'll just add myself onto the list of webforum haters.

I find gmane over a news reader much more comfortable that any webforums I 
have used.

Perhaps gmane can be used over a web interface?

Then those that want to use a web forum have one, and I can continue to use 
my news reader.

When I want to read the lists when I am away from the newsreader then I use 
www.netvibes.com. A very nice web interface for reading in my opinion.

Alas no interface for posting.

Rene. 



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


[Haskell-cafe] Re: Re[2]: what is a difference between existential quantification and polymorhic field?

2006-09-21 Thread Benjamin Franksen
Bulat Ziganshin wrote:
 Hello Ross,
 Thursday, September 21, 2006, 12:55:40 PM, you wrote:
 data Ex = forall a. Num a =  Ex a
 
 and
 
 data Po = Po (forall a. Num a = a)
 
 Consider the types of the constructors:
 
 Ex :: forall a. (Num a) = a - Ex
 Po :: (forall a. (Num a) = a) - Po
 
 sorry, Ross, can you give me a more detailed explanation? it seems
 that Po argument is existential by itself, 

The Po argument is a polymorphic function, not an existential.

As I understand it, the constructor Ex _is_ a polymorphic function, whereas
the constructor Po (only) _takes_as_argument_ a polymorphic function. In
the latter case you store a polymorphic function inside your data, whereas
in the former case you construct (monomorphic) data in a polymorphic way,
which means that during the process you loose the concrete type of the
argument.

Ben

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


Re: [Haskell-cafe] Re: Re: Haskell web forum

2006-09-21 Thread Sebastian Sylvan

On 9/21/06, Rene de Visser [EMAIL PROTECTED] wrote:

I'll just add myself onto the list of webforum haters.

I find gmane over a news reader much more comfortable that any webforums I
have used.



Just to be clear. Is it worth debating which is better? Some people
prefer one over the other, fine. The original topic was do we need a
web forum, not which do you personally prefer.

I think it's quite clear that web forums are more used than mailing
lists by the general public (perhaps not by academics and
professionals, though), so it certainly wouldn't hurt to have one --
regardless of any personal preferences people may have.

I do think we should try to do better than the usual suspects that are
available though. Maybe even write something in Haskell? Are we
allowed to install basically anything we want on the server, or is it
restricted somehow?

/S
--
Sebastian Sylvan
+46(0)736-818655
UIN: 44640862
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Re: Haskell web forum

2006-09-21 Thread David House

On 21/09/06, Sebastian Sylvan [EMAIL PROTECTED] wrote:

I do think we should try to do better than the usual suspects that are
available though. Maybe even write something in Haskell?


This sounds like a good test of maturity for Haskell web platforms.
I'd love to be involved in a collaboration for this, should one be
drummed together. I asked the #haskell IRC channel whether such
software already existed:

shapr   dmhouse: The comment plugin for Hope would be easily hacked
into forum software.
shapr   You'd only need to change it so that a top level message would
be a comment that's not attached to anything.

Although if the design requires it, it might be easier to write one
from scratch.

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


Re[2]: [Haskell-cafe] [newbie] How to test this function?

2006-09-21 Thread Bulat Ziganshin
Hello Bruno,

Thursday, September 21, 2006, 6:16:49 PM, you wrote:

 Second, I want to test this function, without hitting the filesystem.
 In
 C++ I would use a istringstream.  I couldn't find a function that  
 returns
 a Handle from a String.

 http://haskell.org/haskellwiki/Library/Streams

 I'll give this a try.

btw, although this may be considered as bug, it's possible to use
Streams to combine getContents and other I/O on the same stream:

h - openFD test ReadMode
str - vGetContents h
print (take 5 str)
c - vGetChar h
print с
print (take 5 str)

:)  so it's possible to use Streams to simplify your program. of
course, you should understand how it works in order to use it in safe
manner and that means that you should understand how
unsafeInterleaveIO works. look at my today message in haskell list and
expalanation of unsafePerformIO in IO inside


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Re: [newbie] How to test this function?

2006-09-21 Thread David House

On 21/09/06, Benjamin Franksen [EMAIL PROTECTED] wrote:

Emacs is evil!


I'll ignore the throwaway flaimbait there ;)


It also inserts random tab characters into your code just to save a few
space bytes. Tends to completely trash indentation e.g. when pasting code
into mails etc.


Not once happened to me when writing Haskell code. It does annoy you
when writing Lisp, but it takes a single line of config to turn it
off.

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


Re: [Haskell-cafe] Trouble with simple embedding of shell in haskell

2006-09-21 Thread Donn Cave
On Thu, 21 Sep 2006, George Brewster wrote:

 I'm just tried writing a function to allow convenient embedding of shell
 commands, but I'm running into behavior I don't really understand 
 somewhere at the intersection of lazy evaluation, IO, and threading.

You may also find some unwelcome surprises in the area of pipes and
buffered I/O, that aren't specifically about Haskell.  Are you on a
UNIX platform?

I rewrote your function by removing both instances of forkIO, and
it worked about like I expected.  (The last one encounters an error
broken pipe when it tries to write there to the echo hi shell
process, because that process exits instead of reading from its input.)

I can't say whether you really need forkIO, or whether it's really going
to do what you need - not only do I not know enough about the thread
model, neither do I know what you're really trying to do.

Donn Cave, [EMAIL PROTECTED]

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


Re: [Haskell-cafe] Non-existant existential?

2006-09-21 Thread Jim Apple

On 9/21/06, Bruno Oliveira [EMAIL PROTECTED] wrote:

Have you tried to type check this example (the g)?


No. Please excuse me, as I wasn't by my GHC at the time. Let's try:

data SimpExist a = Base a
| SimpExist (SimpExist (forall x . x - a))
g :: SimpExist (forall a . a - a)
g = Base id
h = SimpExist g

data WrapExist = forall a . WrapExist (SimpExist a)
i = WrapExist h

I'm familiar with the use for forall to mean exists, but I am
baffled by h's ineffable type!

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


[Haskell-cafe] Polymorphism/monomorphism (and the restriction)

2006-09-21 Thread Aaron McDaid

Hi,
I think the following might help a little in understanding the 
monomorphic restriction (which I don't fully understand myself). I'm a 
bit of a newbie so apologies in advance if I've made a mistake or if my 
description isn't as useful to others as it seems to me. I've been 
following a thread on haskell@haskell.org and I think the below might 
help. I used GHCi, version 6.2.2 (it fails in hugs but that seems to be 
because of hugs non-compliance with the standard in this case).


First off, I'm guessing that I'm getting Haskell98 behaviour here and 
not some GHCi extension. Please tell me if this is not the case.


Run the code listing at the bottom of this email and you should get the 
output which I've also listed below.
This code experiments with Int, Float and (Num a) = a, and I 
tried to print x*2 and x/2 for each. (4::Int)/2 isn't allowed because / 
isn't defined for Ints.


You can see that
kN :: (Num a) = a
took two different types depending on what method ( / or * ) was applied 
to it.

kN / 2 = 2.0
kN * 2 = 8
kN/2 is a Float (it can't use Int as / isn't defined for Int, so it uses 
Float, for which / is defined).

kN*2 is an Int.
The above outputs demonstrates polymorphism, doesn't it? i.e. Not only 
has the compiler got a variety of types to choose from, but a variety of 
types can be used at runtime?


The output for kI and kF is obvious.

The interesting thing is that k behaves as a Float in both cases. This 
is monomorphism isn't it? i.e. the compiler may have a variety of types 
to choose from, but it picks one and sticks to it for every usage. In 
summary, k didn't give the same outputs as kN.


And the monomorphism restriction is a rule which means that sometimes 
things are forced to a monomorphic type (like k as Float here) when it 
could have given it a polymorphic type like kN :: (Num a) = a


I'm fairly new to these lists, so apologies if I'm covering old ground 
again. My first aim is to understand exactly what polymorphism and 
monomorphism is and demonstrate corresponding results, before thinking 
about the restriction.


Thanks,
Aaron

-- The code
kI :: Int
kI = 4

kF :: Float
kF = 4

kN :: (Num a) = a
kN = 4

k = 4

main = do
p kI * 2 $ kI * 2
p kF / 2 $ kF / 2
p kF * 2 $ kF * 2
p kN / 2 $ kN / 2
p kN * 2 $ kN * 2
p k  / 2 $ k / 2
p k  * 2 $ k * 2

p :: (Show a) = String - a - IO ()
p s = putStrLn.(s++).( = ++).show


-- the output - remember kI / 2 is not possible.
kI * 2 = 8
kF / 2 = 2.0
kF * 2 = 8.0
kN / 2 = 2.0
kN * 2 = 8
k  / 2 = 2.0
k  * 2 = 8.0

-- PS: If you delete the k / 2 line from the program, then k * 2 becomes 
simply 8 (not 8.0). It uses Int if possible, and Float if that's not 
available.

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


Re: [Haskell-cafe] Non-existant existential?

2006-09-21 Thread Jim Apple

When I look at the generated core, I see that both h and

same = Base undefined

have the same type:

%forall a . main:Fonly.SimpExist a

I'm using GHC 6.5.20060819.

If this is a bug, I actually find it kind of useful, for reasons I can
elaborate later.

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


[Haskell-cafe] Re: Trouble with simple embedding of shell in haskell

2006-09-21 Thread George Brewster

Donn Cave wrote:

On Thu, 21 Sep 2006, George Brewster wrote:



I'm just tried writing a function to allow convenient embedding of shell
commands, but I'm running into behavior I don't really understand 
somewhere at the intersection of lazy evaluation, IO, and threading.



You may also find some unwelcome surprises in the area of pipes and
buffered I/O, that aren't specifically about Haskell.  Are you on a
UNIX platform?

I rewrote your function by removing both instances of forkIO, and
it worked about like I expected.  (The last one encounters an error
broken pipe when it tries to write there to the echo hi shell
process, because that process exits instead of reading from its input.)

I can't say whether you really need forkIO, or whether it's really going
to do what you need - not only do I not know enough about the thread
model, neither do I know what you're really trying to do.

Donn Cave, [EMAIL PROTECTED]


Yup, I'm on linux. My goal is to have a function which gives me a lazy 
string which is the output of a shell command, and takes a string as 
input. In particular, I'd like the shell command to behave lazily (read 
only as much input as is needed, and write only as much output as 
needed), so things like this work (should terminate and print a few 
lines of hi):


main = sh yes hi there = sh head = putStrLn

I tried your suggestion out (remove forkIO), and when I do that, this 
example returns but doesn't print anything. Interestingly, my original 
implementation usually behaves this way also, but occasionally works as 
I would like. I had forked a seperate thread for writing the input 
string to the command so that the writing wouldn't block if the process 
filled up its write buffer and read buffer before we were done writing 
the string to it -- this doesn't seem to really have worked for me though.


For reference, here is the funciton in question:

sh :: String - String - IO String
sh cmd = \input -
 do (stdin, stdout, _, pid) - runInteractiveCommand cmd
forkIO $ hPutStr stdin input  hClose stdin
forkIO $ waitForProcess pid  return ()
hGetContents stdout

-George

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


[Haskell-cafe] Re: [newbie] How to test this function?

2006-09-21 Thread Bruno Martínez
On Thu, 21 Sep 2006 15:12:07 -0300, Benjamin Franksen  
[EMAIL PROTECTED] wrote:



OK.  Thanks.  I didn't find that one because it's not offered as an
identation option in emacs haskell mode.


Emacs is evil!


I'm open to alternatives.  I use Windows, so went out of the way to have  
emacs.  What do you use?  I don't care much for colors, but automatic  
identation is very handy (when it works :D).


Bruno

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


Re: [Haskell-cafe] Re: Trouble with simple embedding of shell in haskell

2006-09-21 Thread Donn Cave
On Thu, 21 Sep 2006, George Brewster wrote:
...
 Yup, I'm on linux. My goal is to have a function which gives me a lazy 
 string which is the output of a shell command, and takes a string as 
 input. In particular, I'd like the shell command to behave lazily (read 
 only as much input as is needed, and write only as much output as 
 needed), so things like this work (should terminate and print a few 
 lines of hi):
 
 main = sh yes hi there = sh head = putStrLn

Good luck!

 I tried your suggestion out (remove forkIO), and when I do that, this 
 example returns but doesn't print anything.

For me, it hangs - since I left the wait in.  If I omit the wait, it's
broken pipe, I think because we're trying to write data to head
after it exits.

Donn Cave, [EMAIL PROTECTED]

 sh :: String - String - IO String
 sh cmd = \input -
   do (stdin, stdout, _, pid) - runInteractiveCommand cmd
  forkIO $ hPutStr stdin input  hClose stdin
  forkIO $ waitForProcess pid  return ()
  hGetContents stdout

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