Re: [Haskell-cafe] (no subject)

2009-10-15 Thread wren ng thornton

Jake McArthur wrote:

staafmeister wrote:

Yes I know but there are a lot of problems requiring O(1) array updates
so then you are stuck with IO again


Or use ST. Or use IntMap (which is O(log n), but n is going to max out 
on the integer size for your architecture, so it's really just O(32) or 
O(64), which is really just constant time).


Actually, IntMap is O(min(n,W)) where W is the number of bits in an Int. 
Yes, IntMaps are linear time in the worst case (until they become 
constant-time). In practice this is competitive with all those O(log n) 
structures though.


Whereas Data.Map is O(log n) for the usual balanced tree approach.

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


Re: [Haskell-cafe] (no subject)

2009-10-15 Thread Eugene Kirpichov
There are also the judy arrays
http://hackage.haskell.org/package/HsJudy
http://hackage.haskell.org/package/judy

dons recently advertised the latter as being 2x faster than IntMap,
but I don't know in what respect these two packages differ and why Don
decided to create 'judy' despite the existence of HsJudy.

2009/10/15 wren ng thornton w...@freegeek.org:
 Jake McArthur wrote:

 staafmeister wrote:

 Yes I know but there are a lot of problems requiring O(1) array updates
 so then you are stuck with IO again

 Or use ST. Or use IntMap (which is O(log n), but n is going to max out on
 the integer size for your architecture, so it's really just O(32) or O(64),
 which is really just constant time).

 Actually, IntMap is O(min(n,W)) where W is the number of bits in an Int.
 Yes, IntMaps are linear time in the worst case (until they become
 constant-time). In practice this is competitive with all those O(log n)
 structures though.

 Whereas Data.Map is O(log n) for the usual balanced tree approach.

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




-- 
Eugene Kirpichov
Web IR developer, market.yandex.ru
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] is proof by testing possible?

2009-10-15 Thread wren ng thornton

Joe Fredette wrote:

I fiddled with my previous idea -- the NatTrans class -- a bit, the results
are here[1], I don't know enough really to know if I got the NT law 
right, or

even if the class defn is right.

Any thoughts? Am I doing this right/wrong/inbetween? Is there any use 
for a class
like this? I listed a couple ideas of use-cases in the paste, but I have 
no idea of

the applicability of either of them.

/Joe

http://hpaste.org/fastcgi/hpaste.fcgi/view?id=10679#a10679


A few problems there:

(1) The |a| should be natural, i.e. universally qualified in the class 
methods, not an argument of the typeclass.


(2) Just because there's a natural transformation from F to G does not 
mean there's a related natural transformation back. The law you want is,


forall (X :: *) (Y :: *) (f :: X - Y).
eta_Y . fmap_F f == fmap_G f . eta_X

(3) There can be more than one natural transformation between two 
functors. Which means a type class is the wrong way to go about things 
since there can only be one for the set of type parameters. Consider for 
instance:


type F a = [a]
type G a = [a]

identity :: F a - G a
identity [] = []
identity (x:xs) = (x:xs)

reverse :: F a - G a
reverse = go []
where
go ys [] = ys
go ys (x:xs) = go (x:ys) xs

nil :: F a - G a
nil = const []

...

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


Re: Re[2]: [Haskell-cafe] GHC devs

2009-10-15 Thread David Virebayre
On Wed, Oct 14, 2009 at 11:06 PM, Bulat Ziganshin
bulat.zigans...@gmail.com wrote:
 Hello Andrew,

 Thursday, October 15, 2009, 12:54:37 AM, you wrote:

 Does anybody actually get paid to develop GHC? Or is this all people

 SPJ, SM and Ian are paid by MS Research. Other people involved in core
 development are mainly scientists (afaik)

Taking the opportunity to thank very much both Simons and Ian for the
work they do and the enthusiasm they show. You guys rock.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Parsec bug, or...?

2009-10-15 Thread wren ng thornton

Uwe Hollerbach wrote:

Yes, I've looked at that and am thinking about it. I'm not quite
certain it's needed in my real program... I seem to have convinced
myself that if I actually specify a proper set of unique prefixes, ie,
set the required lengths for both frito and fromage to 3 in the
test program, I won't get into this situation. Assuming I haven't
committed another brain-fart there, that would be sufficient;
presumably, in a real program one would want to actually specify the
unique prefix, rather than a non-unique pre-prefix. It seems to work
fine in my real program, anyway.


Another approach ---assuming you're not wedded to Parsec--- would be to 
construct a trie, e.g. with bytestring-trie[1]. Then use 
Data.Trie.submap to look up the query. If the result is unique then you 
go with it, if not then list the submap's keys in your error message.


The big benefit of this approach is that you needn't maintain a list of 
lengths for disambiguating the keys, the trie does that for you.



[1] 
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/bytestring-trie


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


RE: [Haskell-cafe] Monotype error

2009-10-15 Thread Simon Peyton-Jones
It's a poor error message, but GHC's entire handling of impredicative 
polymorphism is poor at the moment.  Indeed, I'm seriously considering removing 
it altogether until we can come up with a more robust story.  (So don't rely on 
it!)

The error happens because you are trying to use the type (forall a. a) in a 
context that requires a monotype (one with no foralls).  I have not stared at 
the typing rules (in our papers) to convince myself that your program does 
transgress them; indeed, I regard the necessity to do so as evidence that the 
approach is not robust.

Simon

| -Original Message-
| From: haskell-cafe-boun...@haskell.org 
[mailto:haskell-cafe-boun...@haskell.org] On
| Behalf Of Martijn van Steenbergen
| Sent: 14 October 2009 19:35
| To: Haskell Cafe
| Subject: [Haskell-cafe] Monotype error
| 
| Dear café,
| 
|  {-# LANGUAGE Rank2Types #-}
|  {-# LANGUAGE ImpredicativeTypes #-}
| 
|  type Void = forall a. a
| 
|  newtype Mono a = Mono { runMono :: [Void] }
| 
|  beep :: Mono a - Mono a
|  beep (Mono vs) = Mono (map undefined vs)
| 
| Compiling this with GHC results in:
| 
|  Monotype.hs:9:28:
|  Cannot match a monotype with `Void'
|Expected type: Void
|Inferred type: a
| 
| What does this error mean and why does the code not compile?
| 
| Thanks!
| 
| Martijn.
| ___
| 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] Monotype error

2009-10-15 Thread Vladimir Reshetnikov
See our previous discussion on this topic here:
http://www.nabble.com/Fwd:-Unification-for-rank-N-types-td23942179.html

Thanks,
Vladimir

On Wed, Oct 14, 2009 at 10:35 PM, Martijn van Steenbergen 
mart...@van.steenbergen.nl wrote:

 Dear café,

  {-# LANGUAGE Rank2Types #-}
 {-# LANGUAGE ImpredicativeTypes #-}

 type Void = forall a. a

 newtype Mono a = Mono { runMono :: [Void] }

 beep :: Mono a - Mono a
 beep (Mono vs) = Mono (map undefined vs)


 Compiling this with GHC results in:

  Monotype.hs:9:28:
Cannot match a monotype with `Void'
  Expected type: Void
  Inferred type: a


 What does this error mean and why does the code not compile?

 Thanks!

 Martijn.
 ___
 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] (no subject)

2009-10-15 Thread Robin Green
At Thu, 15 Oct 2009 10:15:46 +0400,
Eugene Kirpichov wrote:
 but I don't know in what respect these two packages differ and why Don
 decided to create 'judy' despite the existence of HsJudy.

HsJudy doesn't compile against the latest judy library (as Don knew) -
presumably he had a good reason to start a new package instead of
patching the old one.

There should be a way to mark packages as deprecated on hackage, and
at the same time direct people to a more suitable alternative. Aside
from uploading a dummy new version (ugh!), I don't see a way to do
that currently.
-- 
Robin
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Examples/docs for simulated annealing bindings

2009-10-15 Thread Dougal Stanton
I found the HsASA library [1] on Hackage, but there's no documentation
and it's not particularly intuitive. I can't see any obvious way of
choosing initial config or generating new configurations. Google
reveals no one using it. Does anyone have ideas?

[1]: http://hackage.haskell.org/package/HsASA-0.1


Cheers,

D
-- 
Dougal Stanton
dou...@dougalstanton.net // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Relational Algebra

2009-10-15 Thread Günther Schmidt

Hi all,

has anybody already developed an EDSL for relational algebra?

HaskellDB does that, but its current implementation only allows for  
generating SQL, are there other implementations?



Günther

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


Re: [Haskell-cafe] Examples/docs for simulated annealing bindings

2009-10-15 Thread minh thu
2009/10/15 Dougal Stanton dou...@dougalstanton.net:
 I found the HsASA library [1] on Hackage, but there's no documentation
 and it's not particularly intuitive. I can't see any obvious way of
 choosing initial config or generating new configurations. Google
 reveals no one using it. Does anyone have ideas?

 [1]: http://hackage.haskell.org/package/HsASA-0.1

If the wrapping is not too involved, the original documentation [*]
should help...

Cheers,
Thu

[*] http://www.ingber.com/ASA-README.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANNOUNCE: hs-ffmpeg 0.3.2 - Bindings to FFMpeg library

2009-10-15 Thread Vasyl Pasternak
Hello,

I am glad to announce next release of hs-ffmpeg library. Now you could
download it from the Hackage along with the ffmpeg-tutorials, which show
capabilities of this library.

The installation process is a bit tricky now, so welcome to my blog post
http://progandprog.blogspot.com/2009/10/video-processing-on-haskell-easy.html,
where I am describing how to build and install library.

Best regards,
Vasyl Pasternak
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Parsec bug, or...?

2009-10-15 Thread Uwe Hollerbach
Hi, all, thanks for the further inputs, all good stuff to think
about... although it's going to be a little while before I can
appreciate the inner beauty of Doaitse's version! :-) I had considered
the approach of doing a post-parsec verification, but decided I wanted
to keep it all inside the parser, hence the desire to match prefixes
there (and lack of desire to write 'string p | string pr |
string pre ...'.

By way of background, the actual stuff I'm wanting to match is not
food names, but some commands for a small ledger program I'm working
on. I needed something like that and was tired of losing data to
quicken every so often. I realize of course that there are other
excellent ledger-type programs out there, but hey, I also needed
another hacking project. I'll put this onto hackage in a while, once
it does most of the basics of what I need. No doubt the main
differentiator between mine and those other excellent ledger programs
out there will be that mine has fewer features and more bugs...

thanks again, all!

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


Re: [Haskell-cafe] Finally tagless - stuck with implementation of lam

2009-10-15 Thread Jacques Carette

(sorry for the slow reply on this topic...)

Robert Atkey and Oleg presented some very interesting code in response 
to your query.  But some of you might (and should!) be asking why on 
earth did Jacques use unsafePerformIO?, especially when neither Robert 
nor Oleg did.


Simply put: I answered your question exactly as asked, while they 
answered the question you *should* have asked.  At the exact 'type' 
involved in your question, there is no good answer; if you want an 
instance of lam at a monadic type 'directly', you need to 'extract' from 
the monad.  But the point is that that isn't really the right question.  
Rather than requiring complete parametric polymorphism in the 
answer-type, if you allow a little non-uniformity through a simple type 
family, the shift in types is sufficient to no longer require a monadic 
'extract' at all.


But even once you've gotten to that point, that's not enough, because at 
that point you still have the issue of what calling convention (by 
value, name or need) to use.  And figuring that out is rather fun, so 
you got detailed answer from Robert and Oleg explaining that part in 
detail.  Robert carefully used IntT and :- to label the different 
types, and Oleg's code (http://okmij.org/ftp/tagless-final/CB.hs) showed 
how these were really just 'labels', which are useful mnemonics for 
humans, but not essential.


If you dig into our JFP paper describing finally tagless in all its 
gory details, you'll see that we use a poor man's version of type 
families there too (see section 4.3). 


Jacques


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


Re: [Haskell-cafe] Relational Algebra

2009-10-15 Thread Alistair Bayley
 has anybody already developed an EDSL for relational algebra?

 HaskellDB does that, but its current implementation only allows for
 generating SQL, are there other implementations?

Hello Günther,

Ganesh did something called squiggle a while ago:
http://code.haskell.org/squiggle/unstable/

I've done something similar but it's not published or hosted anywhere,
so no link. Can upload it to code.haskell.org if you're interested.

Both of our projects just generate SQL though, AFAIK. Was there
something else you wanted to generate?

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


Re: [Haskell-cafe] Relational Algebra

2009-10-15 Thread Günther Schmidt

Hi Alistair,




Both of our projects just generate SQL though, AFAIK. Was there
something else you wanted to generate?


I wish I could provide a clear answer to that myself, truth is I'm not  
certain myself at the moment.


All this is related to a rl problem I have, it concerns the business logic  
of the app I wrote.


I hindsight it occurred to me that the algorithm can be abstractly  
expressed in terms of relational algebra for which I need an EDSL.


One concrete implementation could then be an interpreter / compiler to  
SQL, if I choose to use a database backend, and another implementation  
could be a interpretor to in-memory data structures (maps, whathaveyou),  
or a debugger to see if I have got the abstract algorithm right.


I had made very good experience with HaskellDB, it was a great help, but  
the DSL of HaskellDB immediately translates to SQL, it's hardwired to do  
so.


With the newer techniques for designing EDSLs (finally tagless in  
particular), I'm considering to roll one myself, and I suppose I'll also  
need HList to do so too.


Quite a number of people on this list also use Haskell for rl  
applications, so I reason that someone must already have tried something  
similar.



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


Re: [Haskell-cafe] Finally tagless - stuck with implementation of lam

2009-10-15 Thread Günther Schmidt

Hi Jacques,

thank you again for your post, better late than never :)!

Let me first apologize to you, I did not immediately recognize you as one  
of the authors of the Finally Tagless paper.


After 2 years now of using haskell at a mere layman's level and  
nevertheless writing better and more concise code than in the 10 years  
before using other languages I was ready to move a step further.


I must admit that things like type arithmetic, monads, functors and  
whathaveyou can be quite intimidating, but the other day I wrote my first  
monad, and it really wasn't that hard at all.


Anyway, so I had managed to improve my code slightly by introducing an  
abstraction, a tiny, trivial, naive DSL. That certainly was an eye-opener.


When you gave me your solution, I realized that while it was correct, that  
just couldn't be the last word on it. Something from Oleg that contains a  
bug? Can't be, I must have a mistake in my thinking here. So I didn't give  
up on Finally Tagless but read everything I could get my hands on, plus  
the responses to my posts were also quite enlightening.


One minor problem with your paper, and other work from Oleg, well to me  
that is, I don't ML. Also Oleg is such an insider sometimes he forgets  
tiny hints for the rest of us. The initial post (not from me) was about  
An issue with finally tagless ... and in Olegs response to that he  
eliminates the problem with ease (I know, typically Oleg). Well as soon as  
I tried that nothing worked until I put the NoImplicitPrelude in there,  
duh.


So at least now I know what to do next:

Design an EDSL taglessly for relational algebra (using HList too)
write one or 2 interpreters / compilers for SQL and in-memory
Dump the code I have written so far and pretend I never had.


Best wishes

Günther





Am 15.10.2009, 17:05 Uhr, schrieb Jacques Carette care...@mcmaster.ca:


(sorry for the slow reply on this topic...)

Robert Atkey and Oleg presented some very interesting code in response  
to your query.  But some of you might (and should!) be asking why on  
earth did Jacques use unsafePerformIO?, especially when neither Robert  
nor Oleg did.


Simply put: I answered your question exactly as asked, while they  
answered the question you *should* have asked.  At the exact 'type'  
involved in your question, there is no good answer; if you want an  
instance of lam at a monadic type 'directly', you need to 'extract' from  
the monad.  But the point is that that isn't really the right question.   
Rather than requiring complete parametric polymorphism in the  
answer-type, if you allow a little non-uniformity through a simple type  
family, the shift in types is sufficient to no longer require a monadic  
'extract' at all.


But even once you've gotten to that point, that's not enough, because at  
that point you still have the issue of what calling convention (by  
value, name or need) to use.  And figuring that out is rather fun, so  
you got detailed answer from Robert and Oleg explaining that part in  
detail.  Robert carefully used IntT and :- to label the different  
types, and Oleg's code (http://okmij.org/ftp/tagless-final/CB.hs) showed  
how these were really just 'labels', which are useful mnemonics for  
humans, but not essential.


If you dig into our JFP paper describing finally tagless in all its  
gory details, you'll see that we use a poor man's version of type  
families there too (see section 4.3). Jacques





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


Re: [Haskell-cafe] CBN, CBV, Lazy in the same final tagless framework

2009-10-15 Thread Jacques Carette
Just a short note to show how the 3 evaluation orders can be written in 
a very symmetric manner:


o...@okmij.org wrote these as:

In call-by-name, we have
lam f   = S . return $ (unS . f . S)

In call-by-value, we have
lam f   = S . return $ (\x - x = unS . f . S . return)

In call-by-need, we have
lam f   = S . return $ (\x - share x = unS . f . S)
  

These can be rewritten as
call-by-name (eta-expanded and application made visible):
   lam f = S . return $ (\x - unS . f . S  $ x)
call-by-value (flip)
   lam f = S . return $ (\x - unS . f . S . return = x)
call-by-need (flip)
   lam f = S . return $ (\x - unS . f . S = share x )

This pushes us to write two helper functions:
execS  :: (IO a - IO b) - IO a - IO b
execS g x = g = share x

execM :: Monad m = (m a - m b) - m a - m b
execM g x = g . return = x

And now, with the magic of slices, we can truly display those 3 in 
highly symmetric fashion:

call-by-name:
   lam f = S . return $ ((unS . f . S) $)
call-by-value (flip)
   lam f = S . return $ ((unS . f . S) `execM`)
call-by-need (flip)
   lam f = S . return $ ((unS . f . S ) `execS`)
(the redundant $ is left in to make the symmetry explicit)

And now we see the pattern:
   lam f = wrap . lift $ ((unwrap . f . wrap) `apply`)
where the names above are meant to be suggestive rather than 'actual' names.

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


Re: [Haskell-cafe] Need help with ghc static compile for cgi using mysql

2009-10-15 Thread Austin King
For now, I've given up on cheap hosting (via statically compiled CGI).

I've created a GHC 6.10.4, cabal-install, Ubuntu 9.04 ec2 instance +
MySQL and it works well.

Running this plus EBS and Elastic IP will run a little over $60 a month. Ouch.

The work going into Haskell Platform is amazing, but...
Haskell needs a better commodity hosting story, to allow for casual,
fun web hacking.

For the record, I tried nearlyfreespeech.net and dreamhost. I wasn't
able to install ghc and cabal due to:
* FreeBSD GHC support (old version)
* FreeBSD library support (no HDBC)
* Linux - Missing 'dev' libraries like zlib and not having root access
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Need help with ghc static compile for cgi using mysql

2009-10-15 Thread John Van Enk
I've run Haskell stuff on VPS hosts like Linode or SliceHost. $20/month is a
lot better than $60.

On Thu, Oct 15, 2009 at 12:32 PM, Austin King sh...@ozten.com wrote:

 For now, I've given up on cheap hosting (via statically compiled CGI).

 I've created a GHC 6.10.4, cabal-install, Ubuntu 9.04 ec2 instance +
 MySQL and it works well.

 Running this plus EBS and Elastic IP will run a little over $60 a month.
 Ouch.

 The work going into Haskell Platform is amazing, but...
 Haskell needs a better commodity hosting story, to allow for casual,
 fun web hacking.

 For the record, I tried nearlyfreespeech.net and dreamhost. I wasn't
 able to install ghc and cabal due to:
 * FreeBSD GHC support (old version)
 * FreeBSD library support (no HDBC)
 * Linux - Missing 'dev' libraries like zlib and not having root access
 ___
 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] Need help with ghc static compile for cgi using mysql

2009-10-15 Thread Jason Dagit
On Thu, Oct 15, 2009 at 10:11 AM, John Van Enk vane...@gmail.com wrote:

 I've run Haskell stuff on VPS hosts like Linode or SliceHost. $20/month is
 a lot better than $60.


lambdabot is currently hosted on the lowest end linode. The biggest hurdle I
hit was that gnu ld is a memory pig when GHC is compiled with split obj.  I
had to build my own ghc (after disabling split obj, not hard but not
adequately documented either) and things seem to be fine now.  Before I
built GHC without split obj I wasn't even able to link Setup.hs to start
building anything.

I would go so far as to recommend GHC HQ do something about the split obj
issue.  I think ideally we need someone to improve gnu ld.

RAM is expensive on the linode so you need to make sure the code you want to
run is memory efficient (swap is prohibitively slow).  Having root and and
nice web control panel is a huge win.  I'm reasonably happy considering the
relative cost.

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


Re: [Haskell-cafe] GHC devs

2009-10-15 Thread Andrew Coppin

Don Stewart wrote:

bulat.ziganshin:
  

Hello Andrew,

Thursday, October 15, 2009, 12:54:37 AM, you wrote:



Does anybody actually get paid to develop GHC? Or is this all people
  

SPJ, SM and Ian are paid by MS Research. Other people involved in core
development are mainly scientists (afaik)



Perhaps these are the three people the speaker was referring to then.

Seems like there are plenty of other people involved though...


Besides MSR and the university groups, the IHG funds Well-Typed to do
development, as well.
  


...not least of all these. ;-) But still, it seems the total GHC 
manpower effort is significantly smaller than I imagined. (Which just 
makes it more impressive that GHC is so good...)


Ah, MSR, the only known Haskell-related enterprise based in the UK. 
Sometimes I have these delusions that I should go ever there and see if 
they'll hire me...


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


Re: [Haskell-cafe] GHC devs

2009-10-15 Thread Daniel Peebles
Well-Typed is in the UK too :)

On Thu, Oct 15, 2009 at 1:52 PM, Andrew Coppin
andrewcop...@btinternet.com wrote:
 Don Stewart wrote:

 bulat.ziganshin:


 Hello Andrew,

 Thursday, October 15, 2009, 12:54:37 AM, you wrote:



 Does anybody actually get paid to develop GHC? Or is this all people


 SPJ, SM and Ian are paid by MS Research. Other people involved in core
 development are mainly scientists (afaik)


 Perhaps these are the three people the speaker was referring to then.

 Seems like there are plenty of other people involved though...

 Besides MSR and the university groups, the IHG funds Well-Typed to do
 development, as well.


 ...not least of all these. ;-) But still, it seems the total GHC manpower
 effort is significantly smaller than I imagined. (Which just makes it more
 impressive that GHC is so good...)

 Ah, MSR, the only known Haskell-related enterprise based in the UK.
 Sometimes I have these delusions that I should go ever there and see if
 they'll hire me...

 ___
 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] GHC devs

2009-10-15 Thread Andrew Coppin

Daniel Peebles wrote:

Well-Typed is in the UK too :)
  


Really? Cool! I wonder where... Oh, Oxford. So also not far from me.

However, given that I can't even construct a simple sentence correctly...


On Thu, Oct 15, 2009 at 1:52 PM, Andrew Coppin
andrewcop...@btinternet.com wrote:
  

Sometimes I have these delusions that I should go ever there and see if
they'll hire me...



...I think we can safely conclude that nobody is going to be interested 
in hiring me. :-/


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


Re: [Haskell-cafe] Need help with ghc static compile for cgi using mysql

2009-10-15 Thread John Dorsey
 lambdabot is currently hosted on the lowest end linode. The biggest hurdle I
[...]

+1.  I use linode for (most of) my Haskell work.

John

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


[Haskell-cafe] ANN: Reverse Dependencies in Hackage (demo)

2009-10-15 Thread Roel van Dijk
Hello,

I have implemented reverse dependencies in Hackage. You can play with
the demo here:

http://bifunctor.homelinux.net/~roel/hackage

I already send a message to Haskell-Cafe, but I made a few changes and
would like some feedback. You can sort the tables of reverse
dependencies by clicking on the column headers. Large tables (base or
the total overview) might take some time. Sorting is done client-side
with a bit of JavaScript.

I added a link to an overview of the reverse dependencies of every
package in hackage. It is sorted by the total number of rev. deps by
default, so the most dependent-on packages (within hackage) are at the
top. In the future such a list might be expanded with other
information, like the download count.

Things I would like feedback on:
- Rev. deps overview for all packages; is it useful?
- If you look at the reverse dependencies for a package like digest
you'll see a list of packages that depend on digest. Next to the names
of the packages that depend on digest are their respective reverse
dependencies. The idea is that you can see which are the most
important (for some value of important) packages that depend on
digest. Is that useful?
- Is this the best way to present the information?

Currently I am working on a patch for the new hackage-server.

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


Re: [Haskell-cafe] ANN: Reverse Dependencies in Hackage (demo)

2009-10-15 Thread Johan Tibell
Hi,

This is really neat.

2009/10/15 Roel van Dijk vandijk.r...@gmail.com:
 Things I would like feedback on:
 - Rev. deps overview for all packages; is it useful?

Yes.

 - If you look at the reverse dependencies for a package like digest
 you'll see a list of packages that depend on digest. Next to the names
 of the packages that depend on digest are their respective reverse
 dependencies. The idea is that you can see which are the most
 important (for some value of important) packages that depend on
 digest. Is that useful?

Yes, I think so.

 - Is this the best way to present the information?

Are the packages with all zeroes in the columns still reverse
dependencies (that don't have any dependencies in turn)?

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


Re: [Haskell-cafe] ANN: Reverse Dependencies in Hackage (demo)

2009-10-15 Thread Roel van Dijk
2009/10/15 Johan Tibell johan.tib...@gmail.com:
 - Is this the best way to present the information?

 Are the packages with all zeroes in the columns still reverse
 dependencies (that don't have any dependencies in turn)?

Yes. They are reverse dependencies which have no reverse dependencies
of their own.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Very evil

2009-10-15 Thread Andrew Coppin

{-# LANGUAGE EmptyDataDecls #-}

module Main (main) where

import Unsafe.Coerce

data Anything

newtype Key x = Key Int deriving Eq

type Dict = [(Key Anything, Anything)]

put :: Key x - x - Dict - Dict
put k' v' = raw (unsafeCoerce k') (unsafeCoerce v')
 where
   raw k0 v0 [] = [(k0,v0)]
   raw k0 v0 ((k,v):zs)
 | k == k0   = (k0 ,v0) :   zs
 | otherwise = (k  ,v ) : raw k0 v0 zs

get :: Key x - Dict - Maybe x
get k' zs = unsafeCoerce (raw (unsafeCoerce k') zs)
 where
   raw k0 [] = Nothing
   raw k0 ((k,v):zs)
 | k == k0   = Just v
 | otherwise = raw k0 zs

main = do
 let k1 = Key 1 :: Key Int
 let k2 = Key 2 :: Key Double
 let k3 = Key 3 :: Key String
 let k4 = Key 4 :: Key Bool

 let d0 = []
 let d1 = put k1  123  d0
 let d2 = put k2  123  d1
 let d3 = put k3 123 d2
 let d4 = put k4 True  d3

 print (get k1 d4)
 print (get k2 d4)
 print (get k3 d4)
 print (get k4 d4)



Unsafe coerce, anyone?

This particular example appears to run without incident, but the GHC 
docs suggest that this is very... well, unsafe. (In particular, the docs 
claim this will fall over on function types.)


I presume there's some less-evil way of doing this?

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


Re: [Haskell-cafe] more improvable randomness

2009-10-15 Thread Henning Thielemann


On Thu, 8 Oct 2009, Michael Mossey wrote:


I wrote some code to model the keystroke-to-keystroke delay in a person
typing, with pseudorandomness. There are two kinds of delays.. one is a
very small delay as the person reaches for a new key (call this 'reach'
delays), the other is a larger delay that represents a pause to think or
to take a break (call this 'break' delays).


Has this to do with your PortMidi problems?


breakSeries :: Int - Int - StdGen - [Float]
breakSeries lowerB upperB gen =
  let (n,gen1) = randomR (lowerB,upperB) gen
  (gen2,gen3) = split gen1
  delay = generate 1 gen2 breakM
  in replicate n 0 ++ [delay] ++ breakSeries lowerB upperB gen3

breakM :: Gen Float
breakM = frequency [ (10, choose( 1::Float   ,  2))
  , (10, choose( 4::Float   ,  6)) ]

test = (print . take 100 . breakSeries 2 4 ) = newStdGen


Gen is from QuickCheck package, isn't it? That can't be mixed with Random 
from 'random' package. You could wrap 'randomR' in a State monad 
('transformers' package), write your own 'frequency' function for that, 
and run that with the seed from 'newStdGen'.

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


Re: [Haskell-cafe] Very evil

2009-10-15 Thread Daniel Peebles
It looks like you may want
http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-Dynamic.html
. It does more or less what you're talking about behind the scenes,
but probably uses the magical Any type to not encounter issues with
functions, and gives you a Nothing if you attempt to coerce it to the
wrong type.

On Thu, Oct 15, 2009 at 5:10 PM, Andrew Coppin
andrewcop...@btinternet.com wrote:
 {-# LANGUAGE EmptyDataDecls #-}

 module Main (main) where

 import Unsafe.Coerce

 data Anything

 newtype Key x = Key Int deriving Eq

 type Dict = [(Key Anything, Anything)]

 put :: Key x - x - Dict - Dict
 put k' v' = raw (unsafeCoerce k') (unsafeCoerce v')
  where
   raw k0 v0 [] = [(k0,v0)]
   raw k0 v0 ((k,v):zs)
     | k == k0   = (k0 ,v0) :           zs
     | otherwise = (k  ,v ) : raw k0 v0 zs

 get :: Key x - Dict - Maybe x
 get k' zs = unsafeCoerce (raw (unsafeCoerce k') zs)
  where
   raw k0 [] = Nothing
   raw k0 ((k,v):zs)
     | k == k0   = Just v
     | otherwise = raw k0 zs

 main = do
  let k1 = Key 1 :: Key Int
  let k2 = Key 2 :: Key Double
  let k3 = Key 3 :: Key String
  let k4 = Key 4 :: Key Bool

  let d0 = []
  let d1 = put k1  123  d0
  let d2 = put k2  123  d1
  let d3 = put k3 123 d2
  let d4 = put k4 True  d3

  print (get k1 d4)
  print (get k2 d4)
  print (get k3 d4)
  print (get k4 d4)



 Unsafe coerce, anyone?

 This particular example appears to run without incident, but the GHC docs
 suggest that this is very... well, unsafe. (In particular, the docs claim
 this will fall over on function types.)

 I presume there's some less-evil way of doing this?

 ___
 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] Parsec bug, or...?

2009-10-15 Thread S. Doaitse Swierstra


On 15 okt 2009, at 16:58, Uwe Hollerbach wrote:


Hi, all, thanks for the further inputs, all good stuff to think
about... although it's going to be a little while before I can
appreciate the inner beauty of Doaitse's version! :-)


The nice thing is that you do not have to understand the inner  
workings ;-} I basically builds a greedy parser for each word to be  
recognised which can stop and assume the rest is there if it can no  
longer proceed (the `opt` is greedy in its left alternative) . Hence  
it recognises the longest possible prefix.
Since my parsers pursue all alternatives in parallel you automatically  
get what you want, without having to indicate prefix lengths, calls to  
try, etc.


The amb combinator has type

amb :: Parser a - Parser [a]

and collects the result from all alternatives its argument parser is  
constructed from; you might say it convert an ambiguous parser to a  
parser with a list as result, hence preventing the rest of the input  
being parsed over and over again. I am currently working on bringing  
back more abstract interpretation in the implementation (i.e. what we  
have had for almost 10 years in the uulib library), but I do not  
expect you to see a lot of that from the outside.


If you want to work with left-recursive parsers (which does not seem  
to be the case), you may revert to more complicated solutions such as  
found in the christmastree (Changing Haskell's Read Implementation  
Such That by Manipulationg Abstract Syntax Trees Read Evaluates  
Efficiently) package if you need to generate parsers online, or to  
happy-based solutions in case your grammar is fixed.



 If you have any questions do not hesitate to ask,
 Doaitse



I had considered
the approach of doing a post-parsec verification, but decided I wanted
to keep it all inside the parser, hence the desire to match prefixes
there (and lack of desire to write 'string p | string pr |
string pre ...'.

By way of background, the actual stuff I'm wanting to match is not
food names, but some commands for a small ledger program I'm working
on. I needed something like that and was tired of losing data to
quicken every so often. I realize of course that there are other
excellent ledger-type programs out there, but hey, I also needed
another hacking project. I'll put this onto hackage in a while, once
it does most of the basics of what I need. No doubt the main
differentiator between mine and those other excellent ledger programs
out there will be that mine has fewer features and more bugs...

thanks again, all!

Uwe


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


[Haskell-cafe] Re: ANN: Reverse Dependencies in Hackage (demo)

2009-10-15 Thread Maurí­cio CA

 You can sort the tables of reverse dependencies by clicking on
 the column headers.

I wouldn't have thought about clicking in the columns headers.
Maybe you could show the order arrow already in the beggining,
before any clicks, this would give a hint.

 - Rev. deps overview for all packages; is it useful?

Sure! Do you think it could be complemented with a graph view? I
liked this, from graphviz page:

http://graphviz.org/Gallery/undirected/softmaint.html

 - Is this the best way to present the information?

Just cosmetics: in the individual package rev. dependencies, what
do you think of using two columns, one for direct dependencies
table and other for indirect dependencies? This would remove the
need for navigation links in the main table.

Also, here, if it's feasible, I think a graph with just the
central package and 1fst and 2nd order dependencies could be
usefull.

Best,
Maurício

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


Re: [Haskell-cafe] Best Editor In Windows

2009-10-15 Thread Tom.Amundsen



Nathan P. Campos wrote:
 
 Hello,
  I'm very new at Haskell, i'm reading a book and starting, but i want to
 know which is the best editor for development under Windows, because now
 i'm using Notepad++(That i use to develop in C++).
 
 Thanks,
  Nathan Paullino Campos
 

If you use emacs, check out http://www.haskell.org/haskell-mode/
-- 
View this message in context: 
http://www.nabble.com/Best-Editor-In-Windows-tp25908187p25917670.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


[Haskell-cafe] Re: Best Editor In Windows

2009-10-15 Thread Stefan Monnier
 I'm very new at Haskell, i'm reading a book and starting, but i want to
 know which is the best editor for development under Windows, because now
 i'm using Notepad++(That i use to develop in C++).

The best editor for development is Emacs, of course.
http://www.gnu.org/software/emacs


Stefan



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


Re: [Haskell-cafe] Re: Best Editor In Windows

2009-10-15 Thread Paulo Tanimoto
Hello!

On Thu, Oct 15, 2009 at 8:10 PM, Stefan Monnier
monn...@iro.umontreal.ca wrote:
 I'm very new at Haskell, i'm reading a book and starting, but i want to
 know which is the best editor for development under Windows, because now
 i'm using Notepad++(That i use to develop in C++).

 The best editor for development is Emacs, of course.
 http://www.gnu.org/software/emacs


        Stefan

I've been using Emacs with haskell-mode that Stefan Monnier created
and maintains, and I have to say, it's fantastic!  On Linux or
Windows, it just works(TM).

Thank you, Stefan!


The only thing I haven't figured out is how to do tab-completion of
words in the ghci buffer.  Do I need to use a different key
combination?  I couldn't find that in the documentation.

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


Re: [Haskell-cafe] Re: Best Editor In Windows

2009-10-15 Thread Gregory Crosswhite
In my humble opinion, one of the best editors for development of all  
time is Leo:


http://webpages.charter.net/edreamleo/front.html

Leo takes the idea of code folding and gives you complete control  
over it.  That is, unlike other editors which only let you fold the  
code inside if/while/for/etc. statements and which only show you an  
outline consisting of a level for files and a level for function, Leo  
lets you structure the levels of your outline arbitrarily so that you  
can fold arbitrary chunks of code and do things like grouping  
together functions and files with a similar purpose or  
implementation.  By structuring your code as an outline, you make it  
easier for others and yourself both to navigate through the code and  
also to see at a glance the high-level structure.


Anyway, just wanted to use this opportunity to plug my favorite  
tool.  :-)  The downside about it is that the implementation sometimes  
feels a bit slow and clunky, so part of me really hopes that at the  
very least people will learn enough about this tool to take its ideas  
and steal them for other editors!


Cheers,
Greg


On Oct 15, 2009, at 6:10 PM, Stefan Monnier wrote:

I'm very new at Haskell, i'm reading a book and starting, but i  
want to
know which is the best editor for development under Windows,  
because now

i'm using Notepad++(That i use to develop in C++).


The best editor for development is Emacs, of course.
http://www.gnu.org/software/emacs


   Stefan



___
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: Best Editor In Windows

2009-10-15 Thread Stefan Monnier
 The only thing I haven't figured out is how to do tab-completion of
 words in the ghci buffer.  Do I need to use a different key
 combination?  I couldn't find that in the documentation.

I think it's just a missing feature.


Stefan

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


[Haskell-cafe] Fwd: [BostonHaskell] Next meeting: October 21st at MIT (32G-882)

2009-10-15 Thread Ravi Nanavati
-- Forwarded message --
From: Ravi Nanavati rav...@alum.mit.edu
Date: Thu, Oct 15, 2009 at 11:07 PM
Subject: [BostonHaskell] Next meeting: October 21st at MIT (32G-882)
To: bostonhask...@googlegroups.com



I'm pleased to announce the October meeting of the Boston Area Haskell
Users' Group.

Based on the feedback from the meeting polls and the constraints of
our speakers, the October meeting has been scheduled for Wednesday,
October 21st from 7pm - 9pm. Like the past three meetings, it will be
held in the MIT CSAIL Reading Room (32-G882, i.e. a room on the 8th
floor of the Gates Tower of the MIT's Stata Center at 32 Vassar St in
Cambridge, MA).

Based on the topic poll (and because he volunteered), our first
speaker will be Brian Sniffen with an introduction to Parsec.
Following his presentation will be our traditional break (with the
now-traditional baked goods).

Our second speaker will be Edward Kmett, who will be picking up the
part of his monoids and parsing presentation that we didn't get to in
August or September (third time's the charm!): A Parallel Parsing
Trifecta: Iteratees, Parsec, and Monoids.

Edward's slides from August are here:
http://comonad.com/reader/wp-content/uploads/2009/08/IntroductionToMonoids.pdf

I'd recommend looking at them if you weren't at the August meeting (or
want a refresher on the material) since the two parts of his
presentation were designed to go concurrently. There's also a preview
of the presentation as part of this post on Edward's blog:
http://comonad.com/reader/2009/iteratees-parsec-and-monoid/

The October attendance poll is at: http://doodle.com/u7762nfxpghsrn2r

As always, responding to this poll will help with two things:
1. Getting an idea of what fraction of the Boston-area Haskell
community can and can't attend this meeting (to help with future
scheduling).
2. Giving me an estimated count of attendees, since I have talked my
wife into baking some more goodies and bringing drinks again.

Helping with BostonHaskell (besides volunteering to speak at future meetings):
1. Sponsorship of refreshments is still being eagerly solicited.
2. Please let me know if you're willing to arrive early (6:30pm) to
help me move refreshments from my car. Based on past experience, I
could use 3-4 volunteers.
3. Please let me know if you're willing to arrive early (6:30pm) to
stand by the door and let people into the 8th floor. I'm guessing 1 or
2 volunteers is enough here.
4. If someone is willing to edit the HaskellWiki page, post to reddit
or otherwise publicize the meeting please just go ahead and do that
(especially as I'm sending this out a bit later than intended).
5. I'm also still having trouble embedding this poll in a page on our
Google Group, so if anyone has any ideas about that, please feel free
to try (any group member can edit pages) and/or offer other
suggestions.

If you have any questions about the meeting please send them to the
BostonHaskell mailing list: bostonhask...@googlegroups.com or contact
me directly.

I look forward to seeing many Boston-area Haskellers at the October meeting!

Thank you,

 - Ravi Nanavati

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups BostonHaskell group.
To post to this group, send email to bostonhask...@googlegroups.com
To unsubscribe from this group, send email to
bostonhaskell+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bostonhaskell?hl=en
-~--~~~~--~~--~--~---
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] GHC devs

2009-10-15 Thread Max Cantor
It is pretty amazing what such a small coterie of devs has  
accomplished in GHC.  Compare this to the thousands that work on GCC/ 
javac/csc and vis studio etc.  So, once again, kudos.


max

On Oct 16, 2009, at 2:30 AM, Andrew Coppin wrote:


Daniel Peebles wrote:

Well-Typed is in the UK too :)



Really? Cool! I wonder where... Oh, Oxford. So also not far from me.

However, given that I can't even construct a simple sentence  
correctly...



On Thu, Oct 15, 2009 at 1:52 PM, Andrew Coppin
andrewcop...@btinternet.com wrote:

Sometimes I have these delusions that I should go ever there and  
see if

they'll hire me...



...I think we can safely conclude that nobody is going to be  
interested in hiring me. :-/


___
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] Very evil

2009-10-15 Thread Luke Palmer
Maybe you would like the hetero-map package.  Its purpose is to do
precisely what you are doing, but in a typesafe way.

On Thu, Oct 15, 2009 at 3:10 PM, Andrew Coppin
andrewcop...@btinternet.com wrote:
 {-# LANGUAGE EmptyDataDecls #-}

 module Main (main) where

 import Unsafe.Coerce

 data Anything

 newtype Key x = Key Int deriving Eq

 type Dict = [(Key Anything, Anything)]

 put :: Key x - x - Dict - Dict
 put k' v' = raw (unsafeCoerce k') (unsafeCoerce v')
  where
   raw k0 v0 [] = [(k0,v0)]
   raw k0 v0 ((k,v):zs)
     | k == k0   = (k0 ,v0) :           zs
     | otherwise = (k  ,v ) : raw k0 v0 zs

 get :: Key x - Dict - Maybe x
 get k' zs = unsafeCoerce (raw (unsafeCoerce k') zs)
  where
   raw k0 [] = Nothing
   raw k0 ((k,v):zs)
     | k == k0   = Just v
     | otherwise = raw k0 zs

 main = do
  let k1 = Key 1 :: Key Int
  let k2 = Key 2 :: Key Double
  let k3 = Key 3 :: Key String
  let k4 = Key 4 :: Key Bool

  let d0 = []
  let d1 = put k1  123  d0
  let d2 = put k2  123  d1
  let d3 = put k3 123 d2
  let d4 = put k4 True  d3

  print (get k1 d4)
  print (get k2 d4)
  print (get k3 d4)
  print (get k4 d4)



 Unsafe coerce, anyone?

 This particular example appears to run without incident, but the GHC docs
 suggest that this is very... well, unsafe. (In particular, the docs claim
 this will fall over on function types.)

 I presume there's some less-evil way of doing this?

 ___
 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