Re: [Haskell-cafe] Re: Difference between div and /

2010-06-03 Thread Henning Thielemann
Richard O'Keefe schrieb:
 
 On Jun 3, 2010, at 1:13 AM, Maciej Piechotka wrote:
 
 On Wed, 2010-06-02 at 14:01 +1200, Richard O'Keefe wrote:
 For what applications is it useful to use the same symbol
 for operations obeying (or in the case of floating point
 operations, *approximating* operations obeying) distinct laws?



 If the given operations do share something in common. For example * is
 usually commutative. However you do use it with quaternions (Hamilton
 product). You even write ij = k despite the fact that ji = -k.
 
 I think you just made my point:  Commutativity is NOT one of the standard
 properties that * is EXPECTED to possess.  However, it IS one of the
 properties that + is expected to possess, which is why Java's abuse of
 + for string concatenation is so bad.

Java's (+) is not even associative:

(text + 2) + 3 = text23
text + (2+3) = text5
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Sockets get bound to wrong port on Windows

2010-06-03 Thread Ketil Malde
Antoine Latter aslat...@gmail.com writes:

   *Main PortNum 
   47138

 The PortNum constructor should rarely be used directly

So, shouldn't the constructor be hidden, and exported from an .Internal
module? 

 - it contains the port number in network-order. You should try:

Or perhaps even better, the type could be:

data PortNum = PortNum { msb, lsb :: Word8 }

so that we avoid this kind of confusion?

-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] The state of Hackage: what are we doing about it?

2010-06-03 Thread Uwe Schmidt
On Thursday 03 June 2010 06:27:43 am Don Stewart wrote:

 I've been posting CSV files of the download statistics here:
 
http://www.galois.com/~dons/hackage/hackage-downloads.csv
 
 The next quarter's aggregated downloads are due soon.
 
 The Arch Haskell site uses these stats to compute some popularity
 metrics:
 
 http://www.galois.com/~dons/arch-haskell-status.html

with that data, it should be rather easy to compute some kind
weights for the packages and to prefer the popular packages during
the search.
In the long run it would be nice to get this statistics more
frequently, e.g. monthly. We see, that within a quarter there are a lot of new
packages.

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


[Haskell-cafe] Process priority

2010-06-03 Thread Andrew Coppin
I've had a hunt around in System.Process, but I can't discover any way 
to adjust the priority of the process you just spawned. Am I missing 
something, or has this just not been implemented yet? (I must confess, I 
don't know whether Windows and Unix both have the same ideas about 
priority numbers...)


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


Re: [web-devel] Re: [Haskell-cafe] Google Summer of Code: BlazeHTML RFC

2010-06-03 Thread Jasper Van der Jeugt
On Thu, May 27, 2010 at 8:31 PM, Matt Parker moonmaster9...@gmail.com wrote:
 will it be possible to easily interleave IO values into the HTML? like
 instead of the [1,2,3]

 ul $ forM_ [1, 2, 3] (li . string . show)

 what if it was a function that returned IO [1,2,3] (maybe 1,2,3 came out of
 a database). will the forM_ handle that OK?

Depends on how you write the code. More precisely, it depends on in
which monad the forM_ takes place. Also, I would not recommend
interleaving IO values into the HTML, because the HTML is pure -- you
usually don't want to mix that with IO. I'd rather write something
like:

numbers - getFromDataBase
return $ ul $ forM_ numbers (li . string . show)

Or it could be possible to store your templates in a separate modules,
and they would all have a pure type signature:

templateX :: Arg1 - Arg2 - Html a

I think this would be the preferred way, because it allows a
separation between the pure View code and the IO-interleaved
Controller code in a web application.

Kind regards,
Jasper Van der Jeugt

On Thu, May 27, 2010 at 8:31 PM, Matt Parker moonmaster9...@gmail.com wrote:
 will it be possible to easily interleave IO values into the HTML? like
 instead of the [1,2,3]

 ul $ forM_ [1, 2, 3] (li . string . show)

 what if it was a function that returned IO [1,2,3] (maybe 1,2,3 came out of
 a database). will the forM_ handle that OK?


 On Thu, May 27, 2010 at 12:19 PM, Matt Parker moonmaster9...@gmail.com
 wrote:

 Blaze HTML looks wonderful to me (especially with the do notation), and
 better then Hamlet for one reason: writing idiomatic haskell for stuff like
 this:

 ul $ forM_ [1, 2, 3] (li . string . show)

 instead of the Hamlet style:

 %ul
   $forall children.person child
 %li $child$

 which, i don't know, for some reason, made me feel like i was back in PHP
 land.

 -matt


 On Thu, May 27, 2010 at 7:08 AM, Alberto G. Corona agocor...@gmail.com
 wrote:

 As a user, I have too many HTML generators, a few of them with Ajax and
 none with server-side event handling (like ASPX or JSPX).  Ajax is
 complicated but server side event handling is  what I really miss because it
 is simple  from the user point of view, my ervents could be handled in
 haskell code rather than in javaScript and I  implicitly could  use the
 advantages of  dinamic HTML and Ajax without the need to know them at all.
 Imagine a dynamic Web application  with 100% haskell code made with
 dynamic widgets created by third party developers.
 So, anyone want to create a HTML templating system with server side event
 handling? It is not terribly hard to do. (I refer to ASP.NET documentation
 or the JavaServer Faces framework).
 By the way, I vote for XML templating or else, combinator templating that
 produce XHML templating because it can be handled by a future graphical IDE.

 2010/5/27 Jasper Van der Jeugt jasper...@gmail.com

 Hey Bas,

  How about also providing an enumerator back-end?
 
  http://hackage.haskell.org/packages/archive/iteratee/0.3.5/doc/html/Data-Iteratee-Base.html#t%3AEnumeratorGM
 
  Then your library can integrate more easily with the snap framework:
  http://snapframework.com

 Sure, I can do that. But I already tested integration with the snap
 framework, the best path here seems to call the `writeLBS` function
 from the snap framework on the `L.ByteString` that BlazeHtml produces
 (`writeLBS` internally uses an enumerator).

 Kind regards,
 Jasper Van der Jeugt

 On Thu, May 27, 2010 at 10:38 AM, Bas van Dijk v.dijk@gmail.com
 wrote:
  Q14: Do you see any problems with respect to integrating BlazeHtml in
  your favourite web-framework/server?
 
  How about also providing an enumerator back-end?
 
  http://hackage.haskell.org/packages/archive/iteratee/0.3.5/doc/html/Data-Iteratee-Base.html#t%3AEnumeratorGM
 
  Then your library can integrate more easily with the snap framework:
  http://snapframework.com
 
  Regards,
 
  Bas
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


 ___
 web-devel mailing list
 web-de...@haskell.org
 http://www.haskell.org/mailman/listinfo/web-devel




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


Re: [Haskell-cafe] How to build an Indicator Type for a type class?

2010-06-03 Thread Steffen Schuldenzucker
On 06/02/2010 03:59 AM, Brent Yorgey wrote:
 Perhaps something here may be of use?
 
   http://okmij.org/ftp/Haskell/types.html#class-based-overloading

Enlightening. Thanks a lot. For the curious, here is my solution:

http://hpaste.org/fastcgi/hpaste.fcgi/view?id=25907#a25907

I'm gonna read the HList paper now...

Best regards,

Steffen

   http://okmij.org/ftp/Haskell/types.html#class-based-dispatch
 
 -Brent
 
 On Mon, May 31, 2010 at 01:32:18PM +0200, Steffen Schuldenzucker wrote:
 Dear Cafe,

 let:

 data True
 data False

 class C a

 (arbitrary instances for C may follow)

 Now, how to obtain an Indicator Type for C, i.e. a type IndC that is 
 defined
 via a type family / fundep / ... , so that

 IndC a = Trueforall a which are instances of C
 IndC a = False   for all other a.

 I've collected some failed approaches here[1]. My key problem is that if I
 define (in the 3rd try):

 instance (C a) = IndC3 a True

 , it does *not* mean Define this instance for all a which are an instance of
 C, but Define the instance IndC3 a True for all types a, but it's not gonna
 work if a is not an instance of C.

 Does anyone have another idea?

 Background:

 After having implemented type-level lists[2] and a quicksort on them[3], I'd
 like to have type-level sets. In their most simple implementation, sets are
 just (unsorted) lists like this:

 data Nil
 data Cons a b
 class Elem x l
 (instances for Elem so that Elem x l iff x is an element of the list l)

 Now I want:

 type family Insert x s :: *

 Insert x s = s   forall (x, s) with (Elem x s)
 Insert x s = Cons x sfor all other (x, s).


 Thanks a lot!

 Steffen


 [1] http://hpaste.org/fastcgi/hpaste.fcgi/view?id=25832#a25832
 [2] Kiselyov, Peyton-Jones, Shan: Fun with type functions

 http://research.microsoft.com/en-us/um/people/simonpj/papers/assoc-types/fun-with-type-funs/typefun.pdf
 [3] I rewrote this algorithm using type families instead of fundeps:

 http://www.haskell.org/haskellwiki/Type_arithmetic#An_Advanced_Example_:_Type-Level_Quicksort
 ___
 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 mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Problems with Haskell Platform

2010-06-03 Thread Pete Chown

Ivan Lazar Miljenovic wrote:


Pete Chown 1...@234.cx writes:



Is there a way of making Cabal install dependencies using the system
package manager, then?



If you mean cabal-install, then no, there's no integration on either
side.


That's what I thought.  As a result of this, you may find that you end 
up creating private builds of packages which are shipped by your 
distribution.  You ask Cabal to install a package, which is not shipped 
by your distribution.  Cabal will then build that package's 
dependencies, *even if* those dependencies should really be installed 
using your distribution's package manager.



This is exactly the same with C programs.


Yes and no.  If I download the source of a C library and build my own 
shared libraries, my programs might not work on machines where the 
distribution's version of that library is in use.  The particular 
problem in the Haskell world, though, is that Cabal will create this 
situation by default.



(I believe current versions of ghc insist on linking entirely
dynamically or entirely statically.  This makes the situation worse,
because the lack of a shared library for X prevents the use of shared
libraries for anything else.)



No, 6.12 defaults to statically but allows dynamic linking as well.


That's not what I meant.  What I meant is that you can't link against 
some Haskell libraries statically, and some dynamically.  When linking C 
this isn't a problem.  If you don't have a shared version of a 
particular library, gcc will pick the static version instead.  You can 
even choose static or dynamic for each individual library:


$ gcc foo.c -o foo -lz
$ ldd foo
linux-gate.so.1 =  (0x00d0b000)
libz.so.1 = /lib/libz.so.1 (0x00dd5000)
libc.so.6 = /lib/tls/i686/cmov/libc.so.6 (0x00152000)
/lib/ld-linux.so.2 (0x00a69000)
$ gcc foo.c -o foo -Wl,-Bstatic -lz -Wl,-Bdynamic
$ ldd foo
linux-gate.so.1 =  (0x00918000)
libc.so.6 = /lib/tls/i686/cmov/libc.so.6 (0x00db)
/lib/ld-linux.so.2 (0x002e5000)


Really?  For C, Gentoo ships very few which either default or have the
option of static libraries, and I assume the same is true for binary
distributions.


Sorry I misunderstood what you were saying; you're right.  I'm not 
familiar with Gentoo, but on Ubuntu virtually everything defaults to 
shared libraries.  You can choose static if you really want it, though, 
as in the example above.


Pete

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


Re: [Haskell-cafe] Re: Difference between div and /

2010-06-03 Thread Maciej Piechotka
On Thu, 2010-06-03 at 12:44 +1200, Richard O'Keefe wrote:
 On Jun 3, 2010, at 1:13 AM, Maciej Piechotka wrote:
 
  On Wed, 2010-06-02 at 14:01 +1200, Richard O'Keefe wrote:
  For what applications is it useful to use the same symbol
  for operations obeying (or in the case of floating point
  operations, *approximating* operations obeying) distinct laws?
 
 
 
  If the given operations do share something in common. For example * is
  usually commutative. However you do use it with quaternions (Hamilton
  product). You even write ij = k despite the fact that ji = -k.
 
 I think you just made my point:  Commutativity is NOT one of the  
 standard
 properties that * is EXPECTED to possess. 

I don't think that many people expect * to be not commutative (I'm not
speaking about people who deal with Mathematics - I mean 'average
person' and 'average programmer'). 


 If you look at the Int and Double instance of Random in
 the Random.hs that comes with Hugs, you'll see they use
 different code.  It's not because of any problem with /
 per se but because they need genuinely different algorithms.
 
 

Point taken.

Regards


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


[Haskell-cafe] Re: Re: Difference between div and /

2010-06-03 Thread Maciej Piechotka
On Wed, 2010-06-02 at 16:11 +0200, Henning Thielemann wrote:
 Sorry, I missed this post.
 
 
 Maciej Piechotka schrieb:
 
  Well - i tried to write some package dealing with distributions etc. 
  
  If you have something like that:
  
  instance ... = Distribution (Linear a) a where
  rand (Linear f s) g =
  let (gf, gt) = genRange g
  (v, g') = next g
  in (g', f + (fromIntegral v * s) / fromIntegral (gt - gf))
  
  (I haven't check it but IMHO it is right implementation)
  
  Now I have following options:
  
   - Implement per Int/Int8/...
   - Implement IntegerLinear and FractionalLinear separatly
 
 That is, what you need is a general division with rounding. But you
 might more generally want a custom type class with a method that selects
 an element from a set for given parameters gf, gt, v. This way, you
 could also handle distributions on Enumeration types. You certainly you
 do not want, say a division operation on Monday, Tuesday, ..., Sunday,
 but having a probability distribution of weekdays is very reasonable.
 
 Btw. you may want to have a look at:
http://hackage.haskell.org/package/probability

Hmm. Thanks - however I fail to figure out how to do something like:

generate a random number with normal distribution with average avg and
standard deviation stdev.

Regards


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


[Haskell-cafe] cabal update doesn't work on Windows XP

2010-06-03 Thread John O'Donnell

Hi,

Has anyone managed to get cabal to run on Windows?  I'm running Windows 
XP.  There are lots of other things, including old version of Haskell 
tools, installed, but it's too costly to try installing cabal on a fresh 
machine image.


Whenever I do cabal update, the response is Unsuccessful HTTP code 
403.  That looks like the hackage server isn't responding, but other 
software tools (browsers, etc) on the computer can download the hackage 
database; the only program that can't get it is cabal.


This problem occurs with all cabal 1.6, 1.8, with downloaded 
executables, with versions I've compiled, with the version in the 
Haskell Platform.


Needless to say, these problems don't occur on Linux.

Best wishes,
John

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


Re: [Haskell-cafe] Wire GUI

2010-06-03 Thread Chaddaï Fouché
On Wed, Jun 2, 2010 at 5:29 PM, Andrew Coppin
andrewcop...@btinternet.com wrote:
 Thanks to the people who replied about this.

 I would also like to thank my ISP for classifying the entire lot as spam and
 not showing it to me. *sigh*

 Blobs sounds interesting, but seems to require wxHaskell rather than Gtk2hs.
 I may be able to use some of the ideas from it though. I haven't had time to
 watch the YouTube video with sound yet.

I note that Sifflet allows you to connect a function to its arguments
and use gtk2hs. It then allows you to move the function and args
around and even rearrange them automatically, so it seems relevant to
your need.

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


RE: [Haskell-cafe] cabal update doesn't work on Windows XP

2010-06-03 Thread Bayley, Alistair
 Whenever I do cabal update, the response is Unsuccessful HTTP code 
 403.  That looks like the hackage server isn't responding, but other 
 software tools (browsers, etc) on the computer can download 
 the hackage database; the only program that can't get it is cabal.

Do you use an http proxy? If so, you'll need to set the HTTP_PROXY env
var.

Alistair

Invesco Fund Managers Limited, Company No. 898166, FSA No. 119298
Invesco Asset Management Limited, Company No. 949417, FSA No. 122674
Invesco Global Investment Funds Limited, Company No. 1046873, FSA No. 141663
Invesco Perpetual Life Limited, Company No. 3507379, FSA No. 188249
Invesco UK Limited, Company No. 3004959

The first four listed companies are authorised and regulated by the Financial
Services Authority.  All companies are incorporated in England and registered
at 30 Finsbury Square, London EC2A 1AG.  UK Group VAT No. 245 055 771.
*
Confidentiality Note: The information contained in this message,
and any attachments, may contain confidential and/or privileged
material. It is intended solely for the person(s) or entity to
which it is addressed. Any review, retransmission, dissemination,
or taking of any action in reliance upon this information by
persons or entities other than the intended recipient(s) is
prohibited. If you received this in error, please contact the
sender and delete the material from any computer.
*

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


Re: [Haskell-cafe] Re: Re: Difference between div and /

2010-06-03 Thread Henning Thielemann


On Thu, 3 Jun 2010, Maciej Piechotka wrote:


Hmm. Thanks - however I fail to figure out how to do something like:

generate a random number with normal distribution with average avg and
standard deviation stdev.


Unfortunately the package is restricted to discrete distributions so far.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANN: random-fu 0.1.0.0

2010-06-03 Thread mokus
Announcing the 0.1.0.0 release of the random-fu library for random
number generation[1].   This release hopefully stabilizes the core
interfaces (those exported from the base module Data.Random).

Warning to anyone upgrading from earlier releases: 'Discrete' has been
renamed 'Categorical', the entropy source classes have been redesigned,
and many things are no longer exported from the root module Data.Random
(In particular, DevRandom - this is not available on windows, so it will
likely move to its own package eventually so that client code dependencies
on it will be made explicit).

Unfortunately, Hackage appears to have choked on some of the package's
dependencies (specifically, 2 dependencies also depend on time, and were
built using different versions)  so its documentation (which I put quite a
bit of work into) is not displayed on the Hackage site.  In the past I
have dealt with that by uploading new versions with hacks to make sure the
thing builds, but I really would rather not continue to do so.  Is there
any procedure by which I can request a manual rebuild of the package so
that its documentation will be generated and displayed?

Incidentally, this is a recurring problem I have run into several times
for several packages.  Can we *please* come up with a way for sdist or
similar to just include pre-built documentation?  Or if I were to spend
some time working on such a thing, would it be accepted (assuming it was
done up to all applicable standards of quality)?

For now, I have added some pre-built haddock docs to the repository so
that they may be browsed online[2] (if code.haskell.org ever starts
responding to my HTTP requests.  It's just not my day today, I guess).

[1] http://hackage.haskell.org/package/random-fu-0.1.0.0
[2] http://code.haskell.org/~mokus/random-fu/doc/haddock/index.html

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


Re: [Haskell-cafe] Re: Re: Difference between div and /

2010-06-03 Thread mokus

 On Thu, 3 Jun 2010, Maciej Piechotka wrote:

 Hmm. Thanks - however I fail to figure out how to do something like:

 generate a random number with normal distribution with average avg and
 standard deviation stdev.

 Unfortunately the package is restricted to discrete distributions so far.

Shameless self-advertisement: The random-fu package (whimsically named,
sorry) implements a modest variety of continuous distributions with what I
believe to be a user-friendly and flexible interface.

This thread inspired me to finish up and upload the 0.1 release (just
announced on haskell-cafe as well).  The public interface is slightly
different from earlier releases and the haddock docs for the new one
failed to build on hackage, but earlier versions have essentially the same
end-user interface aside from some changes in the module export lists so
if you'd like to get an idea of the basic spirit of the system you can
browse the docs for the earlier releases.  Alternatively, feel free to
browse the source and steal some of the implementations (many of which
were, in turn, translated from other sources such as wikipedia or the
Numerical Recipes book).

Unfortunately, the old documentation is much sparser and terser than the
new documentation that failed to build, but if nothing else you can
download and build the docs yourself for the new one.


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


[Haskell-cafe] Efficient string construction

2010-06-03 Thread Kevin Jardine
(I've done a basic Google search on this with no results. Apologies if this has 
been asked before.)

I am coding a web application in which the content is a Unicode string built up 
over multiple functions and maintained in a State structure.

I gather that the String module is inefficient and that Data.Text would be a 
better choice.

Is it more efficient to build up a list of Text objects over time and combine 
them together with a single Data.Text.concat for the final output or to run 
Data.Text.append for each new string so that I am maintaining a single Text 
object rather than a list?

As Data.Text.append requires copying both strings each time, my gut feeling is 
that concat would be much more efficient, but Haskell has surprised me before, 
so I wanted to check.

Kevin


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


Re: [Haskell-cafe] Efficient string construction

2010-06-03 Thread Daniel Fischer
On Thursday 03 June 2010 16:03:11, Kevin Jardine wrote:
 (I've done a basic Google search on this with no results. Apologies if
 this has been asked before.)

 I am coding a web application in which the content is a Unicode string
 built up over multiple functions and maintained in a State structure.

 I gather that the String module is inefficient and that Data.Text would
 be a better choice.

 Is it more efficient to build up a list of Text objects over time and
 combine them together with a single Data.Text.concat for the final
 output or to run Data.Text.append for each new string so that I am
 maintaining a single Text object rather than a list?

 As Data.Text.append requires copying both strings each time, my gut
 feeling is that concat would be much more efficient, but Haskell has
 surprised me before, so I wanted to check.

 Kevin


I'd say, use Data.Text.Lazy and its 'fromChunks' function if you produce 
the string chunkwise. That avoids copying.
Perhaps Data.ByteString[.Lazy].UTF8 is an even better choice than Data.Text 
(depends on what you do).
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Simplest reference for how to build GHC head + get it running w/ cabal/haskell-platform?

2010-06-03 Thread Ryan Newton
What's the easiest reference for how to build GHC head and get it up
and running with cabal/haskell-platform?

I simply installed 6.12 + haskell-platform then built ghc-6.13.xx and
rebuilt only the packages I needed with cabal install --reinstall.
Perhaps this is not the recommended way.

Indeed, something must be wrong because I can't build certain
packages. (I have problems with base dependencies.)  For example:

$ cabal install QuickCheck
Resolving dependencies...
cabal: cannot configure QuickCheck-1.2.0.0. It requires base ==3.*
For the dependency on base ==3.* there are these packages: base-3.0.3.1 and
base-3.0.3.2. However none of them are available.
base-3.0.3.1 was excluded because of the top level dependency base -any
base-3.0.3.2 was excluded because of the top level dependency base -any

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


[Haskell-cafe] Proposal: Sum type branches as extended types (as Type!Constructor)

2010-06-03 Thread Gabriel Riba
Extending sum types with data constructors would spare runtime errors or
exception control, 

when applying functions to inappropriate branches, as in the example ...

   data List a = Nil | Cons a (List a)  -- List!Nil and List!Cons 
-- as extended types


* Actual system, with runtime errors (as in GHC Data.List head) or 
exception throwing

   hd :: List a - a
   hd (Cons x _) - x
   hd Nil - error error: hd: empty list -- error or exception throwing


* Proposed system extending types with constructors as Type!Constructor:

User must do pattern matching before applying the constructor-specific 
type function.

In ''var @ (Constructor _ _)'' the compiler should append the constructor
to the type as a pair (Type, Constructor) as an extended type for ''var'' 

No need for runtime errors or exception control

   hd :: List!Cons a - a

   hd (Cons x _) = x

using it:

   headOf :: List a - Maybe a

   headOf list = case list of

li @ (Cons _ _) - Just hd li  -- extTypeOf li == ( 'List', 'Cons')
  -- should pass typechecker for List!Cons

li @ Nil  - Just hd li -- compiler error !! 
-- extTypeOf ('List','Nil') don't match

_ - Just hd list   -- compiler error !! 
-- extTypeOf ('List',Nothing) don't match


Maybe we could take out importance on the number of _ wildcards (constructor
arity) with a syntax like.
 li @ (Cons ...)
 li @ (Nil ...)


Cheers!

Gabriel Riba Faura.


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


Re: [Haskell-cafe] Efficient string construction

2010-06-03 Thread Kevin Jardine
--- On Thu, 6/3/10, Daniel Fischer daniel.is.fisc...@web.de wrote:

 Perhaps Data.ByteString[.Lazy].UTF8 is an even better
 choice than Data.Text (depends on what you do).

I thought that I had the differences between the three libraries figured out 
but I guess not now from what you say.

I had thought that String was a simple but memory inefficient model, that Text 
was for, well text, and that bytestrings were for binary data (eg. images, 
audio files and applications that required a true view on each text byte).

So why is there a UTF8 implementation for bytestrings? Does that not duplicate 
what Text is trying to do? If so, why the duplication? When is each library 
more appropriate?

Kevin


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


Re: [Haskell-cafe] Proposal: Sum type branches as extended types (as Type!Constructor)

2010-06-03 Thread Thomas Davie

On 3 Jun 2010, at 16:14, Gabriel Riba wrote:

 Extending sum types with data constructors would spare runtime errors or
 exception control, 
 
 when applying functions to inappropriate branches, as in the example ...
 
   data List a = Nil | Cons a (List a)  -- List!Nil and List!Cons 
-- as extended types
 
 
 * Actual system, with runtime errors (as in GHC Data.List head) or 
 exception throwing
 
   hd :: List a - a
   hd (Cons x _) - x
   hd Nil - error error: hd: empty list -- error or exception throwing
 
 
 * Proposed system extending types with constructors as Type!Constructor:
 
 User must do pattern matching before applying the constructor-specific 
 type function.
 
 In ''var @ (Constructor _ _)'' the compiler should append the constructor
 to the type as a pair (Type, Constructor) as an extended type for ''var'' 
 
 No need for runtime errors or exception control
 
   hd :: List!Cons a - a
 
   hd (Cons x _) = x
 
 using it:
 
   headOf :: List a - Maybe a
 
   headOf list = case list of
 
li @ (Cons _ _) - Just hd li  -- extTypeOf li == ( 'List', 'Cons')
  -- should pass typechecker for List!Cons
 
li @ Nil  - Just hd li -- compiler error !! 
-- extTypeOf ('List','Nil') don't match
 
_ - Just hd list   -- compiler error !! 
-- extTypeOf ('List',Nothing) don't match
 
 
 Maybe we could take out importance on the number of _ wildcards (constructor
 arity) with a syntax like.
 li @ (Cons ...)
 li @ (Nil ...)

This looks fairly similar to total functional programming, though putting the 
onus on the caller to make sure it meets preconditions, rather than the callee 
to make sure it's the right type.

In total functional programming we would say

head :: List a - Maybe a
head (Cons x _) = Just x
head Nil = Nothing

We'd then allow the caller to deal with the maybe any way it likes (commonly 
with fmap, or with the maybe function).

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


Re: [Haskell-cafe] Parselib sample

2010-06-03 Thread C K Kashyap
Hey Doaitse,
Could you please post the full code available?

On Thu, Jun 3, 2010 at 1:01 AM, S. Doaitse Swierstra
doai...@swierstra.netwrote:

 If you want to use the easier long-standing libraries from Utrecht, we can
 provide you with a parser for full Haskell, which you can find in the
 Utrecht Haskell Compiler (UHC) distribution.

 In 2002 Alexey Rodriguez produced a C fron-end, using the UUlibs
 combinators. I am attaching the file with the parser so you can take a look.
 If you want to have access to the full compiler, which was not maintained, I
 can make the full code available on a website. I think it is also
 instructive to start with looking at simpler parsers, e.g. for the bibtex
 format, which is available from:


 https://subversion.cs.uu.nl/repos/project.STEC.uulib/uulib/trunk/examples/

 Doaitse


 On 1 jun 2010, at 13:06, C K Kashyap wrote:

 Hi,
 Is there a not-so-trivial parser implementation with Parselib? Parser for a
 C like language would be good.
 I searched and found Haskell++ -
 http://www.cs.chalmers.se/~rjmh/Software/h++.htmlhttp://www.cs.chalmers.se/%7Erjmh/Software/h++.html
 However, I'd prefer to look at a parser for a C like language.

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







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


Re: [Haskell-cafe] Efficient string construction

2010-06-03 Thread Daniel Fischer
On Thursday 03 June 2010 17:26:36, Kevin Jardine wrote:
 --- On Thu, 6/3/10, Daniel Fischer daniel.is.fisc...@web.de wrote:
  Perhaps Data.ByteString[.Lazy].UTF8 is an even better
  choice than Data.Text (depends on what you do).

 I thought that I had the differences between the three libraries figured
 out but I guess not now from what you say.

 I had thought that String was a simple but memory inefficient model,
 that Text was for, well text, and that bytestrings were for binary data
 (eg. images, audio files and applications that required a true view on
 each text byte).

Well, not necessarily. 
String can be quite memory efficient. As a stupid example,

length (replicate 1000 'a')

will need less memory than the equivalents using ByteString or Text.
Less stupidly, if the String is lazily produced and consumed from head to 
last, String is memory efficient. And it's not necessarily much slower than 
ByteString or Text.

In fact, String is sometimes faster than Text (cf. e.g.
http://www.haskell.org/pipermail/haskell-cafe/2010-May/078220.html and 
following).

When you have to deal with text that is ASCII or latin1 (or some other 
encoding with a byte - char correspondence), plain ByteStrings are 
usually by far the fastest method. But that's of course a severe 
restriction.


 So why is there a UTF8 implementation for bytestrings? Does that not
 duplicate what Text is trying to do? If so, why the duplication?

I think Data.ByteString.UTF8 predates Data.Text.

 When is each library more appropriate?

Generally, ByteString for binary data or text, when you know it's safe and 
you need the speed.
For text, either String or Data.Text may be the better choice.
IIRC, Data.Text uses utf-16 (or some other 16-bit encoding), so if you 
receive utf-8 encoded text, Data.ByteString.UTF8 can be the better choice.
I haven't much experience with either Data.Text or Data.ByteString.UTF8, so 
I can't say much about their relative merits.


 Kevin

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


Re: [Haskell-cafe] design question/font metrics

2010-06-03 Thread Christopher Done
Maybe you could check out the FTGL package for inspiration on  using
the freetype as a conventional C library. I was going to try to write
a Hackage package but realised I know nothing about typography and had
to start reading the intro. on Freetype's homepage (which is pretty
good, actually). Maybe I'll try it on the weekend. I needed something
to measure the size in pixels of some text for a given font and point
size, so I used libgd and manually analysed the pixels. It wasn't fast
but it worked perfectly. So, Gery, if you don't really need speed all
that much, that's a quick route to success. Otherwise maybe we could
work on something with the Freetype library.

On 1 June 2010 18:22, Stephen Tetley stephen.tet...@gmail.com wrote:
 Hi Brandon

 Even that's not simple - freetype is essentially a framework for
 writing font processors rather than a conventional C library[*]. Saner
 perhaps is to write a C program using freetype to do the exact job you
 have in mind, then bind to your C program.

 Best wishes

 Stephen

 [*} Probably why several people Including me have attempted a binding,
 but no-one has delivered one.

 On 1 June 2010 17:18, Brandon S. Allbery KF8NH allb...@ece.cmu.edu wrote:

 The saner way to do this is to write a binding to freetype2.
 ___
 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] Efficient string construction

2010-06-03 Thread Edward Kmett
You might also look at Data.Rope from the rope library, which provides an
O(1) append for strict bytestring chunks, and the ability to decode UTF-8
chars from the result.

http://hackage.haskell.org/packages/archive/rope/0.6.1/doc/html/Data-Rope.html

I'd also be happy to work with you if the current API falls short of your
needs.

-Edward Kmett

On Thu, Jun 3, 2010 at 10:03 AM, Kevin Jardine kevinjard...@yahoo.comwrote:

 (I've done a basic Google search on this with no results. Apologies if this
 has been asked before.)

 I am coding a web application in which the content is a Unicode string
 built up over multiple functions and maintained in a State structure.

 I gather that the String module is inefficient and that Data.Text would be
 a better choice.

 Is it more efficient to build up a list of Text objects over time and
 combine them together with a single Data.Text.concat for the final output or
 to run Data.Text.append for each new string so that I am maintaining a
 single Text object rather than a list?

 As Data.Text.append requires copying both strings each time, my gut feeling
 is that concat would be much more efficient, but Haskell has surprised me
 before, so I wanted to check.

 Kevin



 ___
 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] Proposal: Sum type branches as extended types (as Type!Constructor)

2010-06-03 Thread Ozgur Akgun
On 3 June 2010 16:14, Gabriel Riba griba2...@gmail.com wrote:

 Maybe we could take out importance on the number of _ wildcards
 (constructor
 arity) with a syntax like.
 li @ (Cons ...)
 li @ (Nil ...)



can't you already use {} to get rid of the underscores?

li@(Cons {})
li@(Nil  {})

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


Re: [Haskell-cafe] The state of Hackage: what are we doing about it?

2010-06-03 Thread Don Stewart
si:
 On Thursday 03 June 2010 06:27:43 am Don Stewart wrote:
 
  I've been posting CSV files of the download statistics here:
  
 http://www.galois.com/~dons/hackage/hackage-downloads.csv
  
  The next quarter's aggregated downloads are due soon.
  
  The Arch Haskell site uses these stats to compute some popularity
  metrics:
  
  http://www.galois.com/~dons/arch-haskell-status.html
 
 with that data, it should be rather easy to compute some kind
 weights for the packages and to prefer the popular packages during
 the search.
 In the long run it would be nice to get this statistics more
 frequently, e.g. monthly. We see, that within a quarter there are a lot of new
 packages.

I have scripts, and access to the apache logs -- so its just a matter of
free time to work on this. That's the goal though.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Sockets get bound to wrong port on Windows

2010-06-03 Thread Matthias Reisner

Am 03.06.2010 07:34 schrieb Bardur Arantsson:

On 2010-06-03 05:10, Matthias Reisner wrote:

Hi,

there's something wrong with port numbers in the Network.Socket module
of package network. Printing values gives:

*Main PortNum 
47138
*Main PortNum 47138




Try

   (fromIntegral ) :: PortNumber

(Yes, it's weird.)

Cheers,

Bardur

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



Hi Bardur,

indeed, this is weird. Thanks for the hint!


Regards,

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


Re: [Haskell-cafe] Sockets get bound to wrong port on Windows

2010-06-03 Thread Matthias Reisner

Am 03.06.2010 08:05 schrieb Ketil Malde:

Antoine Latter aslat...@gmail.com writes:

  

  *Main PortNum 
  47138
  


  

The PortNum constructor should rarely be used directly



So, shouldn't the constructor be hidden, and exported from an .Internal
module? 

  

- it contains the port number in network-order. You should try:



Or perhaps even better, the type could be:

data PortNum = PortNum { msb, lsb :: Word8 }

so that we avoid this kind of confusion?

-k
  


Hi,

since this is really not obvious, I'd second to hide the constructor or 
at least a note should be added to the docs how to use PortNumber correctly.



Regards,

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


Re: [Haskell-cafe] Process priority

2010-06-03 Thread Roman Cheplyaka
* Andrew Coppin andrewcop...@btinternet.com [2010-06-03 08:27:21+0100]
 I've had a hunt around in System.Process, but I can't discover any
 way to adjust the priority of the process you just spawned. Am I
 missing something, or has this just not been implemented yet? (I must
 confess, I don't know whether Windows and Unix both have the same
 ideas about priority numbers...)

For POSIX systems you have 'nice' and 'setProcessPriority' in
System.Posix.Process.

-- 
Roman I. Cheplyaka :: http://ro-che.info/
Don't let school get in the way of your education. - Mark Twain
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Proposal: Sum type branches as extended types (as Type!Constructor)

2010-06-03 Thread Jake McArthur

On 06/03/2010 10:14 AM, Gabriel Riba wrote:

No need for runtime errors or exception control

hd :: List!Cons a -  a

hd (Cons x _) = x


This is already doable using GADTs:

data Z
data S n

data List a n where
  Nil :: List a Z
  Cons :: a - List a n - List a (S n)

hd :: List a (S n) - a
hd (Cons x _) = x

tl :: List a (S n) - List a n
tl (Cons _ xs) = xs

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


[Haskell-cafe] Cabal -j

2010-06-03 Thread Louis Wasserman
What, if anything, stands in the way of parallelizing Cabal installs, make
-j style?
Louis Wasserman
wasserman.lo...@gmail.com
http://profiles.google.com/wasserman.louis
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Weird socket problem on Mac OS X

2010-06-03 Thread Arnaud Bailly
Hello,
I have the following code which works ok on Linux and Windows XP, but
fails on Mac OS X with error message:

Connect: does not exist (connection refused)

The server:

doStartstate = do pr - liftIO $ runProcess  ...
liftIO $ threadDelay 50
   st - get
   put st { slimHandle = Just pr }


The client:

fetchAnswers st msgs = liftIO $! do let port = PortNumber $
fromInteger $ port $ config st
cnx - connectTo localhost port

Help most welcome, thanks

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


Re: [Haskell-cafe] ANN: random-fu 0.1.0.0

2010-06-03 Thread Alexander Solla


On Jun 3, 2010, at 6:34 AM, mo...@deepbondi.net wrote:


Announcing the 0.1.0.0 release of the random-fu library for random
number generation[1].   This release hopefully stabilizes the core
interfaces (those exported from the base module Data.Random).


Great work, I'm upgrading now.

The only feature suggestion I can suggest is the addition of a  
convolution operator to combine distributions (reified as RVar's in  
this implementation, though of course the difference between a random  
variable over a distribution and the distribution is rather thin)

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


Re: [Haskell-cafe] Cabal -j

2010-06-03 Thread Don Stewart
wasserman.louis:
 What, if anything, stands in the way of parallelizing Cabal installs, make -j
 style?

Parallelizing ghc --make

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


Re: [Haskell-cafe] Cabal -j

2010-06-03 Thread Christopher Done
On 4 June 2010 00:05, Don Stewart d...@galois.com wrote:
 wasserman.louis:
 What, if anything, stands in the way of parallelizing Cabal installs, make -j
 style?

 Parallelizing ghc --make

    http://vimeo.com/6572966

Unless Louis meant what's stopping cabal-install from installing
dependancies in parallel instead of serial? In which case; nothing?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Efficient string construction

2010-06-03 Thread Bryan O'Sullivan
On Thu, Jun 3, 2010 at 9:16 AM, Daniel Fischer daniel.is.fisc...@web.dewrote:

 String can be quite memory efficient. As a stupid example,

 length (replicate 1000 'a')

 will need less memory than the equivalents using ByteString or Text.


Actually, this will be fused with Data.Text, and should execute more quickly
and in less space than String.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Cabal -j

2010-06-03 Thread Don Stewart
chrisdone:
 On 4 June 2010 00:05, Don Stewart d...@galois.com wrote:
  wasserman.louis:
  What, if anything, stands in the way of parallelizing Cabal installs, make 
  -j
  style?
 
  Parallelizing ghc --make
 
     http://vimeo.com/6572966
 
 Unless Louis meant what's stopping cabal-install from installing
 dependancies in parallel instead of serial? In which case; nothing?
 

Oh, sorry, dependencies (package level parallelism) vs modules (ghc --make 
level parallelism)

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


Re: [Haskell-cafe] Cabal -j

2010-06-03 Thread Louis Wasserman
Heh, I'm interested in both, but I'm feeling like I needed a new project,
and I thought this might make a good one =)

Louis Wasserman
wasserman.lo...@gmail.com
http://profiles.google.com/wasserman.louis


On Thu, Jun 3, 2010 at 5:42 PM, Don Stewart d...@galois.com wrote:

 chrisdone:
  On 4 June 2010 00:05, Don Stewart d...@galois.com wrote:
   wasserman.louis:
   What, if anything, stands in the way of parallelizing Cabal installs,
 make -j
   style?
  
   Parallelizing ghc --make
  
  http://vimeo.com/6572966
 
  Unless Louis meant what's stopping cabal-install from installing
  dependancies in parallel instead of serial? In which case; nothing?
 

 Oh, sorry, dependencies (package level parallelism) vs modules (ghc --make
 level parallelism)

 -- don

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


Re: [Haskell-cafe] Data.ByteString.Lazy.hPut and timeouts?

2010-06-03 Thread Bryan O'Sullivan
On Wed, Jun 2, 2010 at 7:55 PM, Jeremy Shaw jer...@n-heptane.com wrote:


 I know that some OSes provide a per socket timeout that I can set in my
 application code (instead of a system-wide timeout that can only be set by
 root). But that does not seem like a very portable solution.


SO_SENDTIMEO is your portable friend (can't remember whether it's exposed by
the network package, though).
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Proposal: Sum type branches as extended types (as Type!Constructor)

2010-06-03 Thread wren ng thornton

Jake McArthur wrote:

On 06/03/2010 10:14 AM, Gabriel Riba wrote:

No need for runtime errors or exception control

hd :: List!Cons a -  a

hd (Cons x _) = x


This is already doable using GADTs:

data Z
data S n

data List a n where
  Nil :: List a Z
  Cons :: a - List a n - List a (S n)

hd :: List a (S n) - a
hd (Cons x _) = x

tl :: List a (S n) - List a n
tl (Cons _ xs) = xs


Sure, it is the whipping boy of dependent types afterall. However,

* Haskell's standard lists (and Maybe, Either,...) aren't GADTs,
* last I heard GADTs are still a ways off from being accepted into haskell',
* and, given that this is the whipping boy of dependent types, you may 
be surprised to learn that pushing the proofs of correctness through for 
the standard library of list functions is much harder than it may at 
first appear. Which is why, apparently, there is no standard library for 
length-indexed lists in Coq.[1]



But more to the point, this proposal is different. Gabriel is advocating 
for a form of refinement types (aka weak-sigma types), not for type 
families. This is something I've advocated for in the past (under the 
name of difference types)[2] and am still an avid supporter of-- i.e., 
I'm willing to contribute to the research and implementation for it, 
given a collaborator familiar with the GHC code base and given 
sufficient community interest.


The reason why length-indexed lists (and other type families) are 
surprisingly difficult to work with is because of the need to manipulate 
the indices in every library function. With refinement types predicated 
on the head constructor of a value, however, there is no need to 
maintain this information throughout all functions. You can always get 
the proof you need exactly when you need it by performing case analysis. 
The benefit of adding this to the type system is that (a) callees can 
guarantee that the necessary checks have already been done, thereby 
improving both correctness and efficiency, and (b) it opens the door for 
the possibility of moving the witnessing case analysis further away from 
the use site of the proof.


While #b in full generality will ultimately lead to things like type 
families, there are still a number of important differences. Perhaps 
foremost is that you needn't define the proof index at the same point 
where you define the datatype. This is particularly important for adding 
post-hoc annotations to standard types like lists, Maybe, Either, etc. 
And a corollary to this is that you needn't settle on a single index for 
an entire programming community, nor do you impose the cost of multiple 
indices on users who don't care about them.


In short, there's no reason why the equality proofs generated by case 
analysis should be limited to type equivalences of GADT indices. Value 
equivalences for ADTs are important too.




[1] Though I'm working on one:
http://community.haskell.org/~wren/coq/vecs/docs/toc.html

[2] http://winterkoninkje.livejournal.com/56979.html

--
Live well,
~wren
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Cabal -j

2010-06-03 Thread Marc Weber
Excerpts from Christopher Done's message of Fri Jun 04 00:39:23 +0200 2010:
 On 4 June 2010 00:05, Don Stewart d...@galois.com wrote:
  wasserman.louis:
  What, if anything, stands in the way of parallelizing Cabal installs, make 
  -j
  style?
 
  Parallelizing ghc --make
 
     http://vimeo.com/6572966
 
 Unless Louis meant what's stopping cabal-install from installing
 dependancies in parallel instead of serial? In which case; nothing?

I think cabal-install compiles Setup without starting ghc or such (I may
be wrong). This would be fixable.

If you want to volunteer try hack-nix. It's based on the Nix
distribution system which provides this feature natively. You can even
ask others computers to help building dependencies quite easily.

Downside: At the moment it will pull all depndencies (including kernel
headers and glibc..) if you install it on a common linux system.

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


Re: [Haskell-cafe] ANN: random-fu 0.1.0.0

2010-06-03 Thread mokus
 The only feature suggestion I can suggest is the addition of a
 convolution operator to combine distributions (reified as RVar's in
 this implementation, though of course the difference between a random
 variable over a distribution and the distribution is rather thin)

I don't think I understand.  My familiarity with probability theory is
fairly light.  Are you referring to the fact that the PDF of the sum of
random variables is the convolution of their PDFs?  If so, the sum of
random variables can already be computed as liftA2 (+) :: Num a = RVar a
- RVar a - RVar a since RVar is an applicative functor (or using liftM2
since it's also a monad).

Or perhaps you mean an operator that would take, say, 2 values of the
'Uniform' data type and return an instance of the 'Triangular' type
corresponding to the convolution of the distributions?

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


Re: [Haskell-cafe] Language Shootout reverse-complement benchmark

2010-06-03 Thread Martin Drautzburg
Inspired by this post I looked at the language shootout. There is one thing 
which strikes me: On

http://shootout.alioth.debian.org/u64/performance.php?test=spectralnorm#about
 
It sais for the spectralnorm benchmark that both Haskel GHC #4 and HaskellGHC 
produce bad output. For GHC I connt see what's wrong because 1.274224153 
seems to be the correct result. But there really seems to be something wrong 
with GHC#4.

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


Re: [Haskell-cafe] Weird socket problem on Mac OS X

2010-06-03 Thread Antoine Latter
Hi Arnaud,

One thing you might want to try is to stop using the PortNumber data
constructor, and instead rely on 'fromInteger' to do the right thing.

The data constructor assumes that it's argument is in network byte order,
which won't always be the case.

It's not obvious that the constructor should be avoided - this is the second
time today I've seen this!

Take care,
Antoine

On Jun 3, 2010 5:13 PM, Arnaud Bailly arnaud.oq...@gmail.com wrote:

Hello,
I have the following code which works ok on Linux and Windows XP, but
fails on Mac OS X with error message:

Connect: does not exist (connection refused)

The server:

   doStartstate = do pr - liftIO $ runProcess  ...
   liftIO $ threadDelay 50
  st - get
  put st { slimHandle = Just pr }


The client:

   fetchAnswers st msgs = liftIO $! do let port = PortNumber $
fromInteger $ port $ config st
   cnx - connectTo localhost port

Help most welcome, thanks

Arnaud
___
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] ANN: random-fu 0.1.0.0

2010-06-03 Thread Alexander Solla


On Jun 3, 2010, at 4:19 PM, mo...@deepbondi.net wrote:


I don't think I understand.  My familiarity with probability theory is
fairly light.  Are you referring to the fact that the PDF of the sum  
of

random variables is the convolution of their PDFs?  If so, the sum of
random variables can already be computed as liftA2 (+) :: Num a =  
RVar a
- RVar a - RVar a since RVar is an applicative functor (or using  
liftM2

since it's also a monad).

Or perhaps you mean an operator that would take, say, 2 values of the
'Uniform' data type and return an instance of the 'Triangular' type
corresponding to the convolution of the distributions?


I think I had something like the former in mind.  I didn't realize  
liftA2/M2 would do it.When I did this last, I just wrote a monadic  
action to sample values from different RVars.  I should learn the  
higher order monad functions.


On the other hand, it might be kind of nice if RVar's knew which PDF  
they are over.  It's hard for me to see how that would be done with  
Haskell.

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


Re: [Haskell-cafe] Re: Problems with Haskell Platform

2010-06-03 Thread Jens Petersen
On 31 May 2010 20:14, Pete Chown 1...@234.cx wrote:
 I was just thinking, interactions between Cabal and the distribution package
 manager could get worse, as shared Haskell libraries become more common.
  Suppose a distribution ships a package 'foo', but not a package 'bar' which
 depends on it.  The 'foo' package includes shared libraries.  The user now
 installs 'bar' using Cabal.  This causes Cabal to install 'foo' (because it
 is a dependency) and it won't use the distribution's package manager.

This is a good valid point and one I have been worrying about myself sometimes.

I often find myself hitting Ctrl-C at cabal install HACKAGE to run
yum install ghc-DEPENDENCY-devel
and before returning to run cabal install again.

It would be nice to automate this in some way - cabal-install plugins, anyone??

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


Re: [Haskell-cafe] Simplest reference for how to build GHC head + get it running w/ cabal/haskell-platform?

2010-06-03 Thread Ivan Miljenovic
On 4 June 2010 00:57, Ryan Newton new...@mit.edu wrote:
 What's the easiest reference for how to build GHC head and get it up
 and running with cabal/haskell-platform?

 I simply installed 6.12 + haskell-platform then built ghc-6.13.xx and
 rebuilt only the packages I needed with cabal install --reinstall.
 Perhaps this is not the recommended way.

You have to rebuild _everything_ with the new version of GHC.

 Indeed, something must be wrong because I can't build certain
 packages. (I have problems with base dependencies.)  For example:

 $ cabal install QuickCheck
 Resolving dependencies...
 cabal: cannot configure QuickCheck-1.2.0.0. It requires base ==3.*
 For the dependency on base ==3.* there are these packages: base-3.0.3.1 and
 base-3.0.3.2. However none of them are available.
 base-3.0.3.1 was excluded because of the top level dependency base -any
 base-3.0.3.2 was excluded because of the top level dependency base -any

Looks like GHC-6.13 has dropped base-3 compatability; as such,
QuickCheck-1.x will not build as there is no variant that works with
base-4.

Is there any particular reason why you're not using QuickCheck-2.y ?

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Proposal: Sum type branches as extended types (as Type!Constructor)

2010-06-03 Thread Ivan Miljenovic
On 4 June 2010 03:18, Ozgur Akgun ozgurak...@gmail.com wrote:
 On 3 June 2010 16:14, Gabriel Riba griba2...@gmail.com wrote:

 Maybe we could take out importance on the number of _ wildcards
 (constructor
 arity) with a syntax like.
         li @ (Cons ...)
         li @ (Nil ...)


 can't you already use {} to get rid of the underscores?

 li@(Cons {})
 li@(Nil  {})

Even better: you shouldn't need the parentheses:

l...@cons{}
l...@nil{}

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Problems with Haskell Platform

2010-06-03 Thread Ivan Miljenovic
On 4 June 2010 10:27, Jens Petersen peter...@haskell.org wrote:
 On 31 May 2010 20:14, Pete Chown 1...@234.cx wrote:
 I was just thinking, interactions between Cabal and the distribution package
 manager could get worse, as shared Haskell libraries become more common.
  Suppose a distribution ships a package 'foo', but not a package 'bar' which
 depends on it.  The 'foo' package includes shared libraries.  The user now
 installs 'bar' using Cabal.  This causes Cabal to install 'foo' (because it
 is a dependency) and it won't use the distribution's package manager.

 This is a good valid point and one I have been worrying about myself 
 sometimes.

 I often find myself hitting Ctrl-C at cabal install HACKAGE to run
 yum install ghc-DEPENDENCY-devel
 and before returning to run cabal install again.

 It would be nice to automate this in some way - cabal-install plugins, 
 anyone??

How difficult is it just to create an RPM for yourself and then put it
up in some repository for other people to use?

I never use cabal-install to install packages at home (with the
exception of testing versions of libraries I'm writing as I'm writing
them); instead I create a new ebuild for whatever I want and then put
that in the Haskell overlay for Gentoo.

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: random-fu 0.1.0.0

2010-06-03 Thread mokus

 On the other hand, it might be kind of nice if RVar's knew which PDF
 they are over.  It's hard for me to see how that would be done with
 Haskell.

If anyone knows a way this could be done while still allowing general
functions to be mapped over RVars, I'd love to hear about it.  My
suspicion though is that it is not possible.  It would be a very similar
problem to computing the inverse of a function since the PDF is a measure
of the size of the preimage of an event in the probability space (if I'm
putting all those words together correctly ;)).

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


Re: [Haskell-cafe] Proposal: Sum type branches as extended types (as Type!Constructor)

2010-06-03 Thread Jason Dagit
On Thu, Jun 3, 2010 at 8:14 AM, Gabriel Riba griba2...@gmail.com wrote:

 Extending sum types with data constructors would spare runtime errors or
 exception control,

 when applying functions to inappropriate branches, as in the example ...

   data List a = Nil | Cons a (List a)  -- List!Nil and List!Cons
-- as extended types


 * Actual system, with runtime errors (as in GHC Data.List head) or
 exception throwing

   hd :: List a - a
   hd (Cons x _) - x
   hd Nil - error error: hd: empty list -- error or exception throwing


 * Proposed system extending types with constructors as Type!Constructor:

 User must do pattern matching before applying the constructor-specific
 type function.

 In ''var @ (Constructor _ _)'' the compiler should append the constructor
 to the type as a pair (Type, Constructor) as an extended type for ''var''

 No need for runtime errors or exception control

   hd :: List!Cons a - a

   hd (Cons x _) = x


How will this proposal scale with data types that have multiple alternatives
that make sense?  No natural examples come to mind so how about a contrived
example:

data List2 a = Nil | Cons a (List2 a) | Cons2 a a (List2 a)

Now I want to define hd for both Cons and Cons2, but not Nil.  Do I use an
either type like this?
hd :: Either (List2!Cons a) (List2!Cons2 a) - a

It seems like some other syntax would be desirable here, maybe:
hd :: List2!{Cons, Cons2} a - a

How should it work for functions where no type signature is supplied?
 Should it infer the type we would now and only enable the subset of
constructors when the type is explicit as above?

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


Re: [Haskell-cafe] ANN: random-fu 0.1.0.0

2010-06-03 Thread wren ng thornton

Richard O'Keefe wrote:

There's something in that package that I don't understand,
and I feel really stupid about this.

data RVarT m a

type RVar = RVarT Identity

class Distribution d t where
rvar :: d t - RVar t
rvarT :: d t - RVarT n t

Where does n come from?


Presumably from universal quantification in rvarT? That is, the 
implementation of rvarT should be polymorphic in n, in which case the 
particular n doesn't matter (as well it shouldn't, since if it did 
that'd interfere with the composability of the transformer).


Though, since RVar is a synonym for RVarT, I can't imagine why rvar is a 
method instead of a shorthand defined outside of the class. (If RVar 
were primitive then I could imagine performance reasons, but since it 
isn't...)


--
Live well,
~wren
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: random-fu 0.1.0.0

2010-06-03 Thread mokus
 There's something in that package that I don't understand,
 and I feel really stupid about this.

 data RVarT m a

 type RVar = RVarT Identity

 class Distribution d t where
  rvar :: d t - RVar t
  rvarT :: d t - RVarT n t

 Where does n come from?


There's no reason to feel stupid when faced with something unfamiliar. 
Even if you are familiar with monad transformers, this may not be a place
you expect to find them, and 'n' in this case would usually be an 'm' in
other places (it is the underlying monad being extended).  Since I'm not
sure at which level your unfamiliarity lies, I'll just give a from-scratch
crash course.  Feel free to ignore as much as is necessary, and please
don't take this long-winded reply as any sort of condescension :).  I'll
refrain from introducing monads and monad transformers, as the internet is
already full enough of those sorts of introductions.

RVarT is a monad transformer that adds a source of random data to a
preexisting monad, the latter being the role the 'n' serves in rvarT's
type.  RVar is just the pure version where the underlying monad
(Identity) is sort of a type-level no-op.  With that background in mind,
the 2 methods of Distribution, rvar and rvarT, are exactly equivalent,
just specialized so that the compiler can avoid unnecessary conversions in
some cases.  The types are even isomorphic, I believe, due to
parametricity.

Both methods take the distribution in question (the d t) and make an
RVarT n t that has that distribution (RVar is RVarT Identity, so n ==
Identity).  The reason the type variable is 'n' instead of 'm' as is more
traditional is related to the types of the function runRVarT and similar
functions for sampling the RVars:

 runRVarT :: (Lift  n m, RandomSource  m s) = RVarT  n a - s - m a

This involves 2 monads, and 'n' was used for the second of them.  For
consistency, 'n' is often used as the name of the corresponding variable
in type signatures using RVarT.  In runRVarT's type, 'n' is the monad
underlying the random variable and 'm' is the monad in which it is being
sampled.  They are allowed to differ so that random variables can be given
more general types.  If they had to be the same, the RVar would have to
carry around the monad in which it would eventually be sampled (and would
incidentally be granted access to all its capabilities via
Control.Monad.Trans.lift, which would be undesirable).  It would also
restrict the monads in which the RVar could be sampled.  With this scheme,
one RVar/RVarT can be sampled in many monads if desired (and I have used
this ability more than once in real code).

Finally, some may still wonder why there is a monad transformer here at
all - a plain RVar would already be sampleable in any monad that can feed
it some random data.  Originally that's what the library had, but a kind
and perceptive contributor (Reiner Pope) rectified that.  As a result, the
same framework supports some really nifty tricks, most importantly the
ability to define random processes reusing all the existing definitions of
random variables.

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


[Haskell-cafe] Issue with connectTo function in network package

2010-06-03 Thread aditya siram
Hi all,
I had an issue where using the connectTo [1] function would fail to
connect to localhost if my wireless card was turned off. The moment
I turned on my wireless connection it worked. But if I use connectTo
with 127.0.0.1 [2] with my network off it works.

I confirmed that localhost' resolves to 127.0.0.1 by pinging
localhost from command line with the Internet off.

Is this a bug in connectTo?

-deech

[1] connectTo localhost (PortNumber some_number)
[2] connectTo 127.0.0.1 (PortNumber some_number)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Cabal -j

2010-06-03 Thread Evan Laforge
On Thu, Jun 3, 2010 at 3:05 PM, Don Stewart d...@galois.com wrote:
 wasserman.louis:
 What, if anything, stands in the way of parallelizing Cabal installs, make -j
 style?

 Parallelizing ghc --make

    http://vimeo.com/6572966

Something I wondered from watching that talk, rather than trying to
make ghc run concurrently internally, can we just have --make, when
faced with multiple possibilities, pick the first one without a
'ModuleName.working' file, create such a working file, and then go to?

Then you can run 'ghc --make X.hs ; ghc --make X.hs ; ...'.

In fact, isn't that what make -j already does?  I could try it with
the old style 'ghc -M' and pure makefile, but it turns out to be a lot
of work to figure out what packages to include and tangle out the
right .o files and whatnot, work that --make does for me.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: random-fu 0.1.0.0

2010-06-03 Thread Alexander Solla


On Jun 3, 2010, at 6:40 PM, mo...@deepbondi.net wrote:


If anyone knows a way this could be done while still allowing general
functions to be mapped over RVars, I'd love to hear about it.  My
suspicion though is that it is not possible.  It would be a very  
similar
problem to computing the inverse of a function since the PDF is a  
measure
of the size of the preimage of an event in the probability space (if  
I'm

putting all those words together correctly ;)).



We don't necessarily have to compute the inverse of the distribution  
via sampling to do it.  It can be done algebraically, in terms of the  
convolution operator.  Since the types are enumerated, wouldn't  
something like... work?


-- A set and binary operation.  We have an algebra.  I like the J for  
'join'.

-- With this algebra, we can use the real-complex analytical methods to
-- interpret the terms later, if we want to actually reify a  
Distribution

-- instance as a Real (Float, Double) function.

 data DistributionJ a = UniformDistribution Uniform a
   | ...
   | ExponentialDistribution Exponential a
   | DistributionJ a `Convolve` (DistributionJ a)


-- I hope I understand the semantics for the PromptT monad.
 newtype RVarT m a = RVarT { unRVarT :: PromptT (Prim,  
DistributionJ) m a }


I guess threading fst and snd in all the low level computations is  
inelegant, but it's a step closer.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe