Re: [Haskell-cafe] Generics for constructing Rows

2009-08-21 Thread José Pedro Magalhães
Hello, On Thu, Aug 20, 2009 at 16:54, Max Desyatov explicitc...@googlemail.comwrote: Sean Leather leat...@cs.uu.nl writes: I'm not sure the problem you're running into is strictly a generic programming (GP) one. Typically, GP takes code that is often written and generalizes it, so that

Re: [Haskell-cafe] Where does documentation get installed with cabal?

2009-08-21 Thread Colin Paul Adams
Antoine == Antoine Latter aslat...@gmail.com writes: Antoine On Thu, Aug 20, 2009 at 8:58 AM, Colin Paul Antoine Adamsco...@colina.demon.co.uk wrote: Hello, I'm trying to find the API documentation for happstack 0.3 (online is for 0.2). So I did:

Re: [Haskell-cafe] Re: Where do I put the seq?

2009-08-21 Thread Peter Verswyvelen
On Fri, Aug 21, 2009 at 5:03 AM, David Menendez d...@zednenem.com wrote: On Thu, Aug 20, 2009 at 6:57 PM, Peter Verswyvelenbugf...@gmail.com wrote: On Thu, Aug 20, 2009 at 11:23 PM, David Menendez d...@zednenem.com wrote: The important things to note are (1) getChar# depends on the

RE: Re[2]: [Haskell-cafe] Re: Where do I put the seq?

2009-08-21 Thread Bayley, Alistair
From: haskell-cafe-boun...@haskell.org [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Bulat Ziganshin To: Peter Verswyvelen But how does GHC implement the RealWorld internally? I guess look the base library sources for RealWorld

Re: Re[2]: [Haskell-cafe] Re: Where do I put the seq?

2009-08-21 Thread Peter Verswyvelen
IO also seems to use unboxed (hence strict?) tuples newtype IO a = IO (State# RealWorld - (# State# RealWorld, a #)) Not sure if this is just for performance, but if the strictness is required, here we have the horrible hack again then (would behave different without it?). I guess it works

Re: [Haskell-cafe] Re: Where do I put the seq?

2009-08-21 Thread Lennart Augustsson
Internally GHC does have to enforce the ordering on IO operations somehow. If there actually was a RealWorld value being passed around you could use some version of seq the guarantees sequential evaluation. But GHC doesn't even pass a RealWorld around, the sequencing is enforced by different

Re: Re[2]: [Haskell-cafe] Re: Where do I put the seq?

2009-08-21 Thread Lennart Augustsson
You need a lot of magic to make the IO monad efficient. You don't really want to pass around (and pattern match on) a RealWorld token, that would be inefficient. On Fri, Aug 21, 2009 at 11:04 AM, Peter Verswyvelenbugf...@gmail.com wrote: IO also seems to use unboxed (hence strict?) tuples

RE: Re[2]: [Haskell-cafe] Re: Where do I put the seq?

2009-08-21 Thread Simon Peyton-Jones
Actually GHC *does* pass around a RealWorld token right through the optimiser. Just at the moment of code generation we drop it, so that it's not *actually* passed. But for almost all of compilation it's just as if it *was*. Simon | -Original Message- | From:

[Haskell-cafe] Re: Keeping an indexed collection of values?

2009-08-21 Thread Heinrich Apfelmus
Heinrich Apfelmus wrote: Job Vranish wrote: I've been in a situation a lot lately where I need to keep a collection of values, and keep track of them by a persistent index. module Store (Key, Store, empty, add, delete, lookup) where newtype Key = Key { int :: Int } empty ::

[Haskell-cafe] How to convert a list to a vector encoding its length in its type?

2009-08-21 Thread Bas van Dijk
Hello, We're working on a Haskell binding to levmar[1] a C implementation of the Levenberg-Marquardt optimization algorithm. The Levenberg-Marquardt algorithm is an iterative technique that finds a local minimum of a function that is expressed as the sum of squares of nonlinear functions. It has

[Haskell-cafe] Re: Parsec lookahead and |

2009-08-21 Thread Christian Maeder
Daniel Fischer wrote: Bad bug in Parsec (from the beginning, the same happens in parsec-2), I'd say. I'd say, its a feature. lookAhead returns whatever its argument returns. So in this case it returns Consumed without consuming. In that case, the comment lookAhead p parses p without

Re: [Haskell-cafe] How to convert a list to a vector encoding its length in its type?

2009-08-21 Thread Miguel Mitrofanov
{-# LANGUAGE UndecidableInstances #-} Ouch! Don't worry, it's just me not liking UndecidableInstances. So instead of passing the parameters as a list I want to pass them as arguments: \x p1 p2 p3 - p1*x^2 + p2*x + p3 Why not use tuples? \x (p1, p2, p3) - p1 * x^2 + p2 * x + p3 Or a

Re: [Haskell-cafe] Re: Parsec lookahead and |

2009-08-21 Thread Martijn van Steenbergen
Thanks for your replies. Job Vranish wrote: Martijn, how did you encounter this problem? My list of input symbols contains some extra information and I was using lookahead to query for that information before doing the actual parsing. I was using it in various places, including a list of

Re: Re[2]: [Haskell-cafe] Re: Where do I put the seq?

2009-08-21 Thread Derek Elkins
On Fri, Aug 21, 2009 at 5:04 AM, Lennart Augustssonlenn...@augustsson.net wrote: On Fri, Aug 21, 2009 at 10:52 AM, Bayley, Alistair alistair.bay...@invesco.com wrote: From: haskell-cafe-boun...@haskell.org [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Bulat Ziganshin To: Peter

Re: [Haskell-cafe] How to convert a list to a vector encoding its length in its type?

2009-08-21 Thread Bas van Dijk
On Fri, Aug 21, 2009 at 2:02 PM, Miguel Mitrofanovmiguelim...@yandex.ru wrote: {-# LANGUAGE UndecidableInstances #-} Ouch! Don't worry, it's just me not liking UndecidableInstances. Without it, GHC doesn't like the 'Arg f ~ b' constraint not being smaller than the instance head in: instance

Re: [Haskell-cafe] Re: Keeping an indexed collection of values?

2009-08-21 Thread Job Vranish
Thanks for all the input! :) My current code (unfinished) is here: http://github.com/jvranish/IndexedCollection/tree/master but I think I'll shorten the names as you suggest. (and add some strictness to availableKeys) I also added an extra phantom type parameter to the collection (and key) so

Re: [Haskell-cafe] How to convert a list to a vector encoding its length in its type?

2009-08-21 Thread Daniel Peebles
I'm pretty sure you're going to need an existential wrapper for your fromList function. Something like: data AnyVector a where AnyVector :: Vector a n - AnyVector a because otherwise you'll be returning different types from intermediate iterations of your fromList function. I was playing with

Re: [Haskell-cafe] How to convert a list to a vector encoding its length in its type?

2009-08-21 Thread Miguel Mitrofanov
Don't worry, it's just me not liking UndecidableInstances. Without it, GHC doesn't like the 'Arg f ~ b' constraint He's probably right. I don't like it either. What will the type of 'levmarHL' look like using tuples or using your special list-like type? I guess it would be something like

Re: [Haskell-cafe] Re: Keeping an indexed collection of values?

2009-08-21 Thread Sebastian Fischer
On Aug 21, 2009, at 5:11 PM, Job Vranish wrote: I also added an extra phantom type parameter to the collection (and key) so that I can prevent keys from being used on different collections even if they hold elements of the same type. I have the impression that this requires explicit type

Re: [Haskell-cafe] How to convert a list to a vector encoding its length in its type?

2009-08-21 Thread Conor McBride
Hi I'm sure it won't be to everyone's taste, but here's what SHE makes of this problem. SHE lives here http://personal.cis.strath.ac.uk/~conor/pub/she {-# OPTIONS_GHC -F -pgmF she #-} {-# LANGUAGE GADTs, KindSignatures, TypeOperators, TypeFamilies, FlexibleContexts,

Re: [Haskell-cafe] Re: Where do I put the seq?

2009-08-21 Thread David Menendez
On Fri, Aug 21, 2009 at 4:37 AM, Peter Verswyvelenbugf...@gmail.com wrote: On Fri, Aug 21, 2009 at 5:03 AM, David Menendez d...@zednenem.com wrote: I'm not sure I understand your question, but I think it's possible to use interact in the way you want. For example, this code behaves correctly

Re: [Haskell-cafe] How to convert a list to a vector encoding its length in its type?

2009-08-21 Thread Jason Dagit
On Fri, Aug 21, 2009 at 4:41 AM, Bas van Dijkv.dijk@gmail.com wrote: My single question is: how can I convert a list to a Vector??? fromList :: [b] - Vector b n fromList = ? A simpler thing to help you see why this is such a problem is, the problem of how to get a type level natural from

[Haskell-cafe] testing par with simple program

2009-08-21 Thread Paolino
Hi, reading a previous thread I got interested. I simplified the example pointed by dons in import Control.Parallel main = a `par` b `pseq` print (a + b ) where a = ack 3 11 b = ack 3 11 ack 0 n = n+1 ack m 0 = ack (m-1) 1 ack m n = ack (m-1) (ack m (n-1)) compiled with

Re: [Haskell-cafe] Right way to implement setPixel function

2009-08-21 Thread CK Kashyap
thank you very much Job. Regards, Kashyap On Thu Aug 20th, 2009 1:13 PM EDT Job Vranish wrote: Opps: setPixel = State setPixel' should be: setPixel x y rgb = State $ setPixel' x y rgb - Job On Thu, Aug 20, 2009 at 1:05 PM, Job Vranish jvran...@gmail.com wrote: Your setPixel function is

Re: [Haskell-cafe] testing par with simple program

2009-08-21 Thread Don Stewart
paolo.veronelli: Hi, reading a previous thread I got interested. I simplified the example pointed by dons in import Control.Parallel main = a `par` b `pseq` print (a + b ) where a = ack 3 11 b = ack 3 11 ack 0 n = n+1 ack m 0 = ack (m-1) 1 ack m n = ack

Re: [Haskell-cafe] How to convert a list to a vector encoding its length in its type?

2009-08-21 Thread David Menendez
On Fri, Aug 21, 2009 at 1:03 PM, Jason Dagitda...@codersbase.com wrote: Even with a type class for our type level numbers I'm at a loss.  I just don't understand how to convert an arbitrary int into an arbitrary but fixed type.  Perhaps someone else on the list knows.  I would like to know,

Re: [Haskell-cafe] How to convert a list to a vector encoding its length in its type?

2009-08-21 Thread Daniel Peebles
Just to expand on David's higher-order function for the original Vector type, we can do: data AnyVec a where AnyVec :: Vec a n - AnyVec a listToVec :: [a] - AnyVec a listToVec = worker AnyVec worker :: (forall n. Nat n = Vec a n - t) - [a] - t worker f [] = f Nil worker f (x:xs) = worker (f .

Re: [Haskell-cafe] testing par with simple program

2009-08-21 Thread Paolino
A better test program import Control.Parallel main = a `par` b `pseq` print (a + b ) where a = ack 3 11 b = fib 39 ack 0 n = n+1 ack m 0 = ack (m-1) 1 ack m n = ack (m-1) (ack m (n-1)) fib 0 = 0 fib 1 = 1 fib n = fib (n-1) + fib (n-2) running it , these are the results

Re: [Haskell-cafe] Re: Keeping an indexed collection of values?

2009-08-21 Thread Job Vranish
It only requires type annotations on your uses of empty (as that is the only way to construct a collection). The phantom type sticks to everything after that. If you don't care to add a signature then things still work just fine, you just won't be prevented from using indexes from the wrong

Re: [Haskell-cafe] testing par with simple program

2009-08-21 Thread Don Stewart
paolo.veronelli: A better test program import Control.Parallel main = a `par` b `pseq` print (a + b ) where a = ack 3 11 b = fib 39 ack 0 n = n+1 ack m 0 = ack (m-1) 1 ack m n = ack (m-1) (ack m (n-1)) fib 0 = 0 fib 1 = 1 fib n = fib (n-1) + fib (n-2)

Re: [Haskell-cafe] How to convert a list to a vector encoding its length in its type?

2009-08-21 Thread Jason Dagit
For some reason I never saw David's reply to my email. On Fri, Aug 21, 2009 at 11:16 AM, Daniel Peeblespumpkin...@gmail.com wrote: Just to expand on David's higher-order function for the original Vector type, we can do: data AnyVec a where  AnyVec :: Vec a n - AnyVec a listToVec :: [a] -

Re: [Haskell-cafe] How to convert a list to a vector encoding its length in its type?

2009-08-21 Thread Bas van Dijk
Thanks for all the advice. I have this so far. Unfortunately I have to use unsafeCoerce: - {-# LANGUAGE EmptyDataDecls #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE RankNTypes #-} module LevMar where

Re: [Haskell-cafe] How to convert a list to a vector encoding its length in its type?

2009-08-21 Thread Bas van Dijk
On Fri, Aug 21, 2009 at 8:50 PM, Jason Dagitda...@codersbase.com wrote:    toPeano :: Int - (forall n. Nat n = n - t) - t This looks a bit more promising.  For those unfamiliar with this form, it is the logical negation of the previous type.  One description is here [1], where it is mentioned

Re: [Haskell-cafe] How to convert a list to a vector encoding its length in its type?

2009-08-21 Thread Daniel Peebles
Hi Bas, I haven't looked at your code too carefully, but unsafeCoerce amounts to proof by violence :) If you want to construct a (much more verbose, probably) real proof of your constraints, you might want to refer to Ryan Ingram's email[1] from a few months ago about lightweight dependent(-ish)

Re: [Haskell-cafe] Re: Where do I put the seq?

2009-08-21 Thread Peter Verswyvelen
On Fri, Aug 21, 2009 at 6:53 PM, David Menendez d...@zednenem.com wrote: You would still need to determine whether you've reached EOF or not, which forces the input to be determined up to the first line-break or EOF. Good point! I actually had it on my TODO list, but that settles it then :)

Re: [Haskell-cafe] How to convert a list to a vector encoding its length in its type?

2009-08-21 Thread David Menendez
On Fri, Aug 21, 2009 at 2:50 PM, Jason Dagitda...@codersbase.com wrote: On Fri, Aug 21, 2009 at 2:03 PM, David Menendezd...@zednenem.com wrote: The problem is that the parameter, n, is part of the input to toPeano, but you need it to be part of the output. To rephrase slightly, you have    

Re: [Haskell-cafe] Re: Where do I put the seq?

2009-08-21 Thread David Menendez
On Fri, Aug 21, 2009 at 3:29 PM, Peter Verswyvelenbugf...@gmail.com wrote: On Fri, Aug 21, 2009 at 6:53 PM, David Menendez d...@zednenem.com wrote: Some people dislike seq because it lets you force strictness in cases where pattern matching cannot (like function arguments), but hardly anyone

Re: [Haskell-cafe] Re: Where do I put the seq?

2009-08-21 Thread Peter Verswyvelen
The question is, in this case when the user gets to see a bit too much of the output before he sees the input, if that really qualifies as an incorrect program. It's a bit in the gray zone I guess. You could even argue that it's a feature that input and output are not really synched, they are

Re: [Haskell-cafe] Re: Where do I put the seq?

2009-08-21 Thread Peter Verswyvelen
typo, sees the input = must enter the input On Fri, Aug 21, 2009 at 10:28 PM, Peter Verswyvelen bugf...@gmail.comwrote: The question is, in this case when the user gets to see a bit too much of the output before he sees the input, if that really qualifies as an incorrect program. It's a bit in

[Haskell-cafe] Fwd: [BostonHaskell] September meeting polls

2009-08-21 Thread Ravi Nanavati
I'm forwarding this to haskell-cafe to catch any current or new Boston-area Haskellers who haven't yet joined the BostonHaskell Google group: http://groups.google.com/group/bostonhaskell If you're interested in Boston-area Haskell activity, please join the Google group so you won't miss out on

[Haskell-cafe] (no subject)

2009-08-21 Thread Stavenga, G.C.
Hi, I'm just started to learn Haskell. Coming from a programming contest background (where it is important to be able to solve problems in a small amount of code) I'm wondering what the best way is for simple IO. A typical input file (in a programming contest) is just a bunch of numbers which

Re: [Haskell-cafe] (no subject)

2009-08-21 Thread Don Stewart
G.C.Stavenga: Hi, I'm just started to learn Haskell. Coming from a programming contest background (where it is important to be able to solve problems in a small amount of code) I'm wondering what the best way is for simple IO. A typical input file (in a programming contest) is just a

[Haskell-cafe] Re: How to convert a list to a vector encoding its length in its type?

2009-08-21 Thread John Lato
From: David Menendez d...@zednenem.com or, equivalently, by using a higher-order function.    toPeano :: Int - (forall n. Nat n = n - t) - t Incidentally, this is the approach used in the type-level library [1], which provides the function: reifyIntegral :: Integral i = i - (forall n.

Re: Re[2]: [Haskell-cafe] Re: Where do I put the seq?

2009-08-21 Thread Lennart Augustsson
The IO in hbc was (is) the old request-response model, on top of which there was also a continuation layer, as well as the monadic IO (once that was invented). It involved a lot more C code handling the requests than I really liked. BTW, unsafePerformIO is pretty ugly to implement in the

Re: [Haskell-cafe] (no subject)

2009-08-21 Thread staafmeister
Don Stewart-2 wrote: G.C.Stavenga: Hi, I'm just started to learn Haskell. Coming from a programming contest background (where it is important to be able to solve problems in a small amount of code) I'm wondering what the best way is for simple IO. A typical input file (in a

[Haskell-cafe] Converting typeset mathematics into Haskell ?

2009-08-21 Thread Mark Wassell
Does anyone know of any papers or projects, either for Haskell or any other language, that relate to what I am going to attempt to describe in the following: Go to any paper or book that includes some amount of calculation type mathematics. An example is the formula in the Description section

Re: [Haskell-cafe] (no subject)

2009-08-21 Thread Sebastian Sylvan
On Fri, Aug 21, 2009 at 11:42 PM, Stavenga, G.C. g.c.stave...@uu.nl wrote: Hi, I'm just started to learn Haskell. Coming from a programming contest background (where it is important to be able to solve problems in a small amount of code) I'm wondering what the best way is for simple IO. A

Re: [Haskell-cafe] Converting typeset mathematics into Haskell ?

2009-08-21 Thread John D. Ramsdell
The purpose of mathematic syntax is to comunicate mathematical ideas between humans. Programmirng languages both communicate mathmatical ideas among humans and specify sequences of operations performed by computing machinery to achieve a goal. The trouble is is the first goal is often

Re: [Haskell-cafe] Unifcation and matching in Abelian groups

2009-08-21 Thread John D. Ramsdell
Let me put all my cards on the table. You see, I really am only slightly irrigated by offset syntax. In contrast, I am a strong proponent of functional programming for parallel programming. In my opinion, it has to be the new way for multiprocessor machines. Just think about it and if other