[Haskell-cafe] question about faulting in Haskell packages ...

2008-08-02 Thread Galchin, Vasili
Hello,

Sorry I asked this question before .. say I want to install package A
that depends on package B, C, D but maybe  B and D are not installed on my
machine. Basically I want to fault in (i.e. install automatically) in B
and D with no fuss no muss. ???
In reality I would like to get my laptop which is running Ubuntu totally
faulted up with all Haskell packages ... ;^)

Regards,

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


Re: [Haskell-cafe] question about faulting in Haskell packages ...

2008-08-02 Thread david48
You need to get cabal-install.
Here's how I got it working on kubuntu :

1) install GHC 6.8.3 from haskell.org's binaries (kubuntu hardy isn't
at 6.8.3 yet)
2) download from hackage :
* cabal-install-0.5.1.tar.gz from hackage
* HTTP-3001.0.4.tar.gz
* zlib-0.4.0.4.tar.gz
* Cabal-1.4.0.1.tar.gz

3) build and install http, zlib, Cabal and then cabal-install

for each package you have to type (*) :

runhaskell Setup.hs configure
runhaskell Setup.hs build
sudo runhaskell Setup.hs install

(*) sometimes it'll be Setup.lhs, I'm annoyed that it's not always the
same name, can't rely on shell history :(

4) once cabal-install is  installed you can do

cabal update
sudo cabal upgrade --global

that'll upgrade all your ghc's packages.

5) from now if you want to install package a just type

cabal install a --global

cabal should download packages b,c,d for you if required.



P.S. Sorry for the previous email, it got sent before I finished it :)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] question about faulting in Haskell packages ...

2008-08-02 Thread Galchin, Vasili
cool david 

1) I have to upgrade to ghc 6.8.3

2) I may/probably will have more questions

very kind thanks,

vasili


On Sat, Aug 2, 2008 at 1:52 AM, david48
[EMAIL PROTECTED][EMAIL PROTECTED]
 wrote:

 You need to get cabal-install.
 Here's how I got it working on kubuntu :

 1) install GHC 6.8.3 from haskell.org's binaries (kubuntu hardy isn't
 at 6.8.3 yet)
 2) download from hackage :
 * cabal-install-0.5.1.tar.gz from hackage
 * HTTP-3001.0.4.tar.gz
 * zlib-0.4.0.4.tar.gz
 * Cabal-1.4.0.1.tar.gz

 3) build and install http, zlib, Cabal and then cabal-install

 for each package you have to type (*) :

 runhaskell Setup.hs configure
 runhaskell Setup.hs build
 sudo runhaskell Setup.hs install

 (*) sometimes it'll be Setup.lhs, I'm annoyed that it's not always the
 same name, can't rely on shell history :(

 4) once cabal-install is  installed you can do

 cabal update
 sudo cabal upgrade --global

 that'll upgrade all your ghc's packages.

 5) from now if you want to install package a just type

 cabal install a --global

 cabal should download packages b,c,d for you if required.



 P.S. Sorry for the previous email, it got sent before I finished it :)

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


Re: [Haskell-cafe] Using fundeps to resolve polymorphic types to concrete types

2008-08-02 Thread iavor . diatchki
Hi,

On 7/29/08, Bryan Donlan [EMAIL PROTECTED] wrote:
 Hi,

 Is there any theoretical reason that functional dependencies can't be used
 to resolve a polymorphic type to a concrete type? For example:

 -- compile with -fglasgow-exts

 class DeriveType a b | a - b

 data A = A
 data B = B

 instance DeriveType A B


 simpleNarrow :: DeriveType A b = b - B
 simpleNarrow = id

 Since 'b' is uniquely determined by the fundep in DeriveType, it seems that
 this ought to work; ie, since the only type equation satisfying DeriveType A
 b
 is B - B, it should reduce to that before trying to fit its type against
 its
 body.

According to the theory of functional dependencies this function
should type check
but there is a bug in the current implementation (or you may view it
as an incompleteness---the compiler is not smart enough to infer that
b in this case is really B while checking the signature).

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


Re: [Haskell-cafe] How can I get the mutable array out of an IOUArray for FFI use?

2008-08-02 Thread Thomas Schilling

Maybe you can rewrite your code using the functions from this module:

http://haskell.org/ghc/docs/latest/html/libraries/array/Data-Array- 
Storable.html


On 29 Jul 2008, at 09:22, Ryan Ingram wrote:


I wrote some fast bit-twiddling functions in C because my Haskell
performance wasn't good enough.  Now I'm trying to recompile with
GHC6.8.3 and failing.   This code worked on GHC6.6.1.

I get the following error:


ghc --make main.hs


Bitmap.hs:11:7:
Could not find module `Data.Array.IO.Internals':
  it is hidden (in package array-0.1.0.0)

I suppose I can declare a copy of the internal type and use
unsafeCoerce#, but that seems like a terrible idea if there is a
better way.  What's the right way to make this work?  Can I force that
module to be unhidden?  Should I file a GHC bug?

  -- ryan

{-# OPTIONS_GHC -fffi -fglasgow-exts #-}
{-# INCLUDE bitmap_operations.h #-}

module Bitmap (
clearBitmap,
) where
import Foreign.Ptr
import Data.Array.Base
import Data.Array.IO.Internals
import GHC.Exts
import Data.Word

foreign import ccall unsafe clear_bitmap :: MutableByteArray#
RealWorld - Word32 - Word32 - IO ()

{-# INLINE unsafeGetMutableArray# #-}
unsafeGetMutableArray# :: IOUArray Int Word32 - MutableByteArray#  
RealWorld

unsafeGetMutableArray# (IOUArray (STUArray _ _ array#)) = array#

clearBitmap :: IOUArray Int Word32 - Word32 - Word32 - IO ()
clearBitmap a1 color size
= clear_bitmap (unsafeGetMutableArray# a1) color size
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


/ Thomas
--
Monkey killing monkey killing monkey over pieces of the ground.
Silly monkeys give them thumbs they forge a blade
And where there's one they're bound to divide it
Right in two



PGP.sig
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] question about faulting in Haskell packages ...

2008-08-02 Thread Niklas Broberg
 for each package you have to type (*) :

 runhaskell Setup.hs configure
 runhaskell Setup.hs build
 sudo runhaskell Setup.hs install

 (*) sometimes it'll be Setup.lhs, I'm annoyed that it's not always the
 same name, can't rely on shell history :(

That's why you should always write e.g. 'runhaskell Setup configure',
since runhaskell is clever enough to figure out the suffix for you.
:-)

Cheers,

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


[Haskell-cafe] Web processing

2008-08-02 Thread Rafael C. de Almeida
Hello,

I understand that nowadays there are several frameworks and wrapper
libraries for making some sense of the XHTML documents you find over the
web. That is, making the life of those who want to process the
semi-structured data you find on the sites.

I don't have much experience on that field myself, but I want to learn a
little more about how I can, for instance, associate information from
one site with information in another site. Even though it is structured
differently in both places. Does anyone know about libraries that would
help me out with that sort of work? Hope I'm being clear.

[]'s
Rafael
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] adjoint of coproduct diagonal

2008-08-02 Thread Jason Dusek
  I'm trying to figure out the adjunction diagrams for the
  adjunction where the diagonal functor is right adjoint to the
  coproduct functor. I'm |almost done|, but the co-unit has me
  stumped, because I can't figure out how the arrow at the top
  can be unique -- it seems it could be either one of:

i_1 . [f,g]
i_2 . [f,g]

  i_1, i_2 : C - C+C
  f : A - C
  g : B - C

  The net effect of [id,id] on the right is to blur out the
  distinction. On #haskell, someone suggested there is a
  constraint I am missing; I've poked around for a day and still
  can't figure it out.

-- 
_jsn


 |almost done|
  http://hpaste.org/9303
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] poll: how can we help you contribute to darcs?

2008-08-02 Thread Jason Dusek
Eric Kow [EMAIL PROTECTED] wrote:
 I would contribute to darcs if only...

  ...there were interest in binary file handling.

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


[Haskell-cafe] Re: Cabal + yi + alex problem.

2008-08-02 Thread Ben Franksen
Austin Seipp wrote:
 For that matter, ghc-pkg list | grep -i alex doesn't list anything,
 after I cabal-installed it.  How does cabal verify the prerequisite alex
 version?  (Or does it?)
 
 ghc-pkg lists libraries that are registered with the ghc package
 manager (globally and locally); alex is simply an application, not a
 library, so there's really nothing for GHC to register. As for telling
 what version is necessary, I haven't the slightest.

Slightly OT, but this division of work between cabal and ghc-pkg has always
looked strange to me. Cabal knows better what meta information to store
about a package, library or application. IMO the package database should
reside with cabal; implementations like ghc or hugs or whatever could query
cabal about the information they need (e.g. for building).

Cheers
Ben

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


Re: [Haskell-cafe] Web processing

2008-08-02 Thread Jeremy Shaw
Hello,

I would recommend using TagSoup:

http://www-users.cs.york.ac.uk/~ndm/tagsoup/

The tutorial easy, and has good advice:

http://www.cs.york.ac.uk/fp/darcs/tagsoup/tagsoup.htm

I would not bother trying to use a real XML parser, because I suspect
that many of the XHTML pages you want to parse, are not actually valid
XHTML, which means the XML parsers will fail. Also, some of the sites
you are interested in might not be XHTML at all. So, using TagSoup for
everything seems simpliest.

The process is very lo-fi. Write some code using TagSoup which scrapes
the data you care about from the web pages and turns it into Haskell
data structures. This code should not be clever, and it will need to
be updating whenever the site you are scraping changes enough to break
your code.

This process should work fine if you are talking about scraping data
from some specific sites.

If you want to make a web crawler which automatically finds relevant
pages and scrapes the data, then that is a much bigger project. You
will still want to use something like TagSoup to do the initial
parsing, but extracting the data will be much trickier (though,
possibly worth billions of $$$ if done well).

j.

ps. I only have experience with TagSoup, so there may be other
libraries which are even better. The key feature of TagSoup is that it
allows you to process malformed, invalid HTML -- which is important if
you don't control the creation of the HTML you are parsing.

At Sat, 02 Aug 2008 22:10:36 -0300,
Rafael C. de Almeida wrote:
 
 Hello,
 
 I understand that nowadays there are several frameworks and wrapper
 libraries for making some sense of the XHTML documents you find over the
 web. That is, making the life of those who want to process the
 semi-structured data you find on the sites.
 
 I don't have much experience on that field myself, but I want to learn a
 little more about how I can, for instance, associate information from
 one site with information in another site. Even though it is structured
 differently in both places. Does anyone know about libraries that would
 help me out with that sort of work? Hope I'm being clear.
 
 []'s
 Rafael
 ___
 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] Web processing

2008-08-02 Thread Don Stewart
jeremy:
 Hello,
 
 I would recommend using TagSoup:
 
 http://www-users.cs.york.ac.uk/~ndm/tagsoup/
 
 The tutorial easy, and has good advice:
 
 http://www.cs.york.ac.uk/fp/darcs/tagsoup/tagsoup.htm
 

There's also a wrapper for this, that uses curl+bytestrings for the
download part, and exposes tags, xml and rss/atom parsers for the
content itself,

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/download-curl

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


Re: [Haskell-cafe] adjoint of coproduct diagonal

2008-08-02 Thread Derek Elkins
On Sat, 2008-08-02 at 18:22 -0700, Jason Dusek wrote:
 I'm trying to figure out the adjunction diagrams for the
   adjunction where the diagonal functor is right adjoint to the
   coproduct functor. I'm |almost done|, but the co-unit has me
   stumped, because I can't figure out how the arrow at the top
   can be unique -- it seems it could be either one of:
 
 i_1 . [f,g]
 i_2 . [f,g]
 
   i_1, i_2 : C - C+C
   f : A - C
   g : B - C
 
   The net effect of [id,id] on the right is to blur out the
   distinction. On #haskell, someone suggested there is a
   constraint I am missing; I've poked around for a day and still
   can't figure it out.

[id,id] is the counit.
[id,id] : C+C - C
Given a function f : A+B - C there exists a unique function
f* : (A,B) - (C,C) that is a pair of functions
h : A - C and k : B - C such that
[id,id] . h+k = f.
The one way is obvious given f, h = f . inL and k = f . inR
So a solution exists.
To show that it is unique assume we are given an h and k such that the
above equation holds we need to show that h = f . inL (and similarly for
k.)
So start by precomposing both sides of the equation with inL giving:
[id,id] . h+k . inL = f . inL
We simply need to show that the left side is h.  The injections together
form the unit.  Naturality of the unit says that for any h and k:
h : A - B
k : C - D
inL . h = h+k . inL
inR . k = h+k . inR
Using this in the above we have:
[id,id] . inL . h = f . inL
Now we use one of the triangle identities which states:
[id,id] . inL = id
[id,id] . inR = id
and this finishes the proof:
id . h = f . inL
h = f . inL

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


[Haskell-cafe] Brainstorming on how to parse IMAP

2008-08-02 Thread John Goerzen
Hi folks,

I'm interested in writing a library to work with IMAP servers.

I'm interested in thoughts people have on parsing libraries and methods.
 I'm a huge fan of Parsec overall -- it lets me have a single-stage
parser, for instance.  But it isn't sufficiently lazy for this task, and
I probably will need to deal with ByteStrings instead of Strings, since
some IMAP messages may be 30MB or more.

So to give a very, very brief rundown of RFC3501, there are lots of ways
that an IMAP server can encode things.   For instance, we could see this:

A283 SEARCH TEXT string not in mailbox

which is the same as:

A283 SEARCH TEXT string not in mailbox

and the same as:

A283 SEARCH {4} string not in mailbox
TEXT

The braces mean that the given number of octets follows after the CRLF
at the end of the given line.  We could even see:

A283 SEARCH {4} {21}
TEXTstring not in mailbox

Note that when downloading messages, I would fully expect to see things like

* FETCH {10485760}

representing a 10MB message.

Also, quoted strings have escaping rules.

[ please note that the above is paraphrased and isn't really true
RFC3501 for simplicity sake ]

Now then...  some goals.

1) Ideally I could parse stuff lazily.  I have tried this with FTP and
it is more complex than it seems at first, due to making sure you never,
never, never consume too much data.  But being able to parse lazily
would make it so incredibly easy to issue a command saying download all
new mail, and things get written to disk as they come in, with no
buffer at all.

2) Avoiding Strings wherever possible.

3) Avoiding complex buffering schemes where I have to manually buffer
data packets.

Thoughts and ideas?

BTW, if any of you have heard of OfflineIMAP, yes I am considering
rewriting OfflineIMAP in Haskell.

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


Re: [Haskell-cafe] adjoint of coproduct diagonal

2008-08-02 Thread Jason Dusek
Derek Elkins [EMAIL PROTECTED] wrote:
 h : A - C and k : B - C
 [...snip...]
 h : A - B
 k : C - D

  Are these the same h and k?

-- 
́́_jsn

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


Re: [Haskell-cafe] adjoint of coproduct diagonal

2008-08-02 Thread Derek Elkins
On Sat, 2008-08-02 at 20:00 -0700, Jason Dusek wrote:
 Derek Elkins [EMAIL PROTECTED] wrote:
  h : A - C and k : B - C
  [...snip...]
  h : A - B
  k : C - D
 
   Are these the same h and k?

No.  As it says in the line just before what you quoted these are -any-
h and k.  They do end up being instantiated to the above h and k albeit
with specializations of the latter types.

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


[Haskell-cafe] code review? store server, 220loc.

2008-08-02 Thread Tim Newsham

Anyone interested in critiquing some code?  I'm looking for ideas
for making it faster and/or simpler:

   http://www.thenewsh.com/%7Enewsham/store/Server5.hs

This is an exercise to see how well a server in Haskell would perform.
My goals are roughly:
- retargetability to other server types (ie. easy to
  replace request and response structures and business logic).
- readability.
- performance.

My measurements show that a simple dummy server (accept, forkio,
recv byte) handles roughly 7500 requests/connects per second,
the server/client that do real messages do about 4500 req and
connections per second.  If all requests are on the same connection
one after another it does about 13500 requests/second.  For
comparisons, a C ping-pong server does about 3600/second if
it has to fork for each new connection/request, and about 35000/sec
if its all on the same connection.  So it seems at least competitive
with a forking C server.  I havent tested threaded C servers.

Tim Newsham
http://www.thenewsh.com/~newsham/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] code review? store server, 220loc.

2008-08-02 Thread Don Stewart
newsham:
 Anyone interested in critiquing some code?  I'm looking for ideas
 for making it faster and/or simpler:
 
http://www.thenewsh.com/%7Enewsham/store/Server5.hs
 
 This is an exercise to see how well a server in Haskell would perform.
 My goals are roughly:
 - retargetability to other server types (ie. easy to
   replace request and response structures and business logic).
 - readability.
 - performance.
 
 My measurements show that a simple dummy server (accept, forkio,
 recv byte) handles roughly 7500 requests/connects per second,
 the server/client that do real messages do about 4500 req and
 connections per second.  If all requests are on the same connection
 one after another it does about 13500 requests/second.  For
 comparisons, a C ping-pong server does about 3600/second if
 it has to fork for each new connection/request, and about 35000/sec
 if its all on the same connection.  So it seems at least competitive
 with a forking C server.  I havent tested threaded C servers.
 

packBS :: String - B.ByteString
packBS = B.pack . map (toEnum.fromEnum)

-- | Convert a bytestring to a string.
unpackBS :: B.ByteString - String
unpackBS = map (toEnum.fromEnum) . B.unpack


are Data.ByteString.Char8.pack/unpack.

What optimisation and runtime flags did you use (-threaded or not?)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe