[Haskell-cafe] Re: monads and groups -- instead of loops

2007-08-02 Thread Greg Meredith
Arie, Thanks for your thoughtful reply. Comments in-lined. Best wishes, --greg Date: Thu, 2 Aug 2007 03:06:51 +0200 (CEST) From: Arie Peterson [EMAIL PROTECTED] Subject: Re: [Haskell-cafe] Re: monads and groups -- instead of loops To: haskell-cafe@haskell.org Message-ID: [EMAIL PROTECTED]

Re: [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-02 Thread Alexis Hazell
On Thursday 02 August 2007 15:57, ok wrote: It all depends on what you mean make sense to. I can tell my student that (an instance of Monad) is a type constructor applications of which support certain operations that must satisfy certain operations. They can memorise that. But it remains

Re: [Haskell-cafe] Some Haskell platformish questions

2007-08-02 Thread Bulat Ziganshin
Hello David, Thursday, August 2, 2007, 12:48:07 AM, you wrote: about concurrency - necessarily read paper Tackling the awkward squad: monadic input/output, concurrency, exceptions, and foreign-language calls in Haskell

Re: [Haskell-cafe] Re: monads and groups -- instead of loops

2007-08-02 Thread Wouter Swierstra
On 1 Aug 2007, at 21:23, Greg Meredith wrote: But, along these lines i have been wondering for a while... the monad laws present an alternative categorification of monoid. At least it's alternative to monoidoid. In the spirit of this thought, does anyone know of an expansion of the monad

Re: [Haskell-cafe] Cartesian product of a Set

2007-08-02 Thread Andy Gimblett
On Thu, Aug 02, 2007 at 04:15:35PM +1200, ok wrote: On the other hand, I've usually found that it pays to avoid explicitly constructing things like Cartesian products. Could that be the case here? Quite possibly, though for my purposes I don't _think_ it's worth routing around it. I'm

Re: [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-02 Thread Dougal Stanton
On 02/08/07, Alexis Hazell [EMAIL PROTECTED] wrote: It's at this point that i feel there's an issue. Haskell Monads are used FOR many many things. And rather than get to the core of what a Monad is, many people provide two or three motivating examples - examples which merely serve to show

[Haskell-cafe] Re: Some Haskell platformish questions

2007-08-02 Thread Niko Korhonen
My answers apply to Windows/GHC. David Pollak wrote: * Can GHC generate stand-alone executables with all the dependencies linked in such that I can distribute the single file without worrying about including a bunch of DLLs/SOs? The answer seems to be yes, but I wanted

[Haskell-cafe] Re: [HOpenGL] renderString problems

2007-08-02 Thread C Flynn
On Wed, 1 Aug 2007, Dave Tapley wrote: Hi all, I'm having a lot of trouble using renderString from Graphics.UI.GLUT.Fonts. All my attempts to render a StrokeFont have so far failed. Using a BitmapFont I can get strings to appear but they demonstrate the odd behaviour of translating themselves

RE: FW: RE [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-02 Thread Bayley, Alistair
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of peterv However, one thing which I find annoying is that a classic pure function cannot evaluate an IO function unless you use unsafePerformIO; one must promote (?demote) the pure function into the IO monad. That's just a

Re: [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-02 Thread Stuart Cook
On 8/2/07, Dougal Stanton [EMAIL PROTECTED] wrote: Do I have an suggestions? Well, maybe the right way would be to do as we do with map and fold, etc: show the explicitly recursive example, then generalise. So, show how we could we would thread state in Haskell, or how we would do optional

Re: [Haskell-cafe] renderString problems

2007-08-02 Thread Stuart Cook
On 8/2/07, Dave Tapley [EMAIL PROTECTED] wrote: Using a BitmapFont I can get strings to appear but they demonstrate the odd behaviour of translating themselves a distance equal to their length every time my displayCallback function is evaluated. I've never used OpenGL from Haskell, but it

Re: [Haskell-cafe] renderString problems

2007-08-02 Thread Claude Heiland-Allen
Hi Dave, everyone... Dave Tapley wrote: Hi all, I'm having a lot of trouble using renderString from Graphics.UI.GLUT.Fonts. All my attempts to render a StrokeFont have so far failed. Using a BitmapFont I can get strings to appear but they demonstrate the odd behaviour of translating themselves

Re: [Haskell-cafe] renderString problems

2007-08-02 Thread Paul L
Your code is not rendering stroke font, but bitmap. Use the following code to render str at x and y position. GL.currentRasterPosition $= vertex4 x y 0 1 GLUT.renderString GLUT.Fixed8By13 str where vertex4 is defined as: vertex4 :: Float - Float - Float - Float - GL.Vertex4 Float

Re: [Haskell-cafe] Installing FreeGLUT

2007-08-02 Thread Paul L
GHC as of now won't be able to recognize your change to the dynamic libraries on the fly. So if you want to use new features, you'll have to compile GLUT package for GHC freshly on top of your new freeglut. Get the GLUT source from hackage.haskell.org and do the cabal installation. GHC will then

Re: [Haskell-cafe] Exiting GLUT application

2007-08-02 Thread Paul L
Are you trying it on Linux? I had exactly the same problem. I believe it's with with X11/OpenGL. I've written C programs using GLUT, freeGLUT and GLFW (another OpenGL Window Kit) to re-open window after first one is closed. Unfortunately all gave the same fault. So it leads me to believe the

[Haskell-cafe] Re: [Haskell] ANN: encoding-0.1 release

2007-08-02 Thread Duncan Coutts
On Thu, 2007-08-02 at 18:44 +0200, Wolfgang Jeltsch wrote: Am Donnerstag, 2. August 2007 12:22 schrieb Henning Günther: […] ISO 8859-* (alias latin-*) Not every ISO-8859-* encoding is a Latin-* encoding. […] Wouldn’t it be good to use some already existing library like iconv

RE: [Haskell-cafe] Re: how to see operators precedence in GHCi

2007-08-02 Thread Simon Peyton-Jones
Hmm. Good point. Fixed. Smion | -Original Message- | From: Stefan O'Rear [mailto:[EMAIL PROTECTED] | Sent: 26 July 2007 01:01 | To: Simon Peyton-Jones | Cc: Bulat Ziganshin; haskell-cafe@haskell.org; Jon Fairbairn | Subject: Re: [Haskell-cafe] Re: how to see operators precedence in GHCi

Re: [Haskell-cafe] Polymorphic variants

2007-08-02 Thread Jon Harrop
On Thursday 26 July 2007 00:07:23 Josef Svenningsson wrote: On 7/26/07, Jon Harrop [EMAIL PROTECTED] wrote: Does Haskell have anything similar to OCaml's polymorphic variants? No as such, but it's possible to simulate them. As always Oleg was the one to demonstrate how:

Re: [Haskell-cafe] Primitive Recursive Algebraic Types

2007-08-02 Thread Alexteslin
Alexteslin wrote: Hi, I am doing some simple exercises about recursive algebraic types and this particular exercise asks to define a function which counts the number of operators in an expression. I defined the function below, but i am not sure if on the second line changing from

[Haskell-cafe] Perfect example

2007-08-02 Thread Jon Harrop
Any suggestions for a perfect example that uniquely demonstrates the benefits of the Haskell language compared to other languages? -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. OCaml for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists/?e

[Haskell-cafe] positive Int

2007-08-02 Thread brad clawsie
as far as i know, the haskell standard does not define a basic Int type that is limited to positive numbers. would a type of this kind not potentially allow us to make stronger verification statements about certain functions? for example, 'length' returns an Int, but in reality it must always

Re: [Haskell-cafe] positive Int

2007-08-02 Thread brad clawsie
On Thu, Aug 02, 2007 at 12:17:06PM -0700, brad clawsie wrote: as far as i know, the haskell standard does not define a basic Int type that is limited to positive numbers. would a type of this kind not potentially allow us to make stronger verification statements about certain functions?

[Haskell-cafe] monad subexpressions

2007-08-02 Thread Chris Smith
I've heard Simon (Peyton-Jones) twice now mention the desire to be able to embed a monadic subexpression into a monad. That would be http://article.gmane.org/gmane.comp.lang.haskell.prime/2267 and in the recent OSCON video. Is someone working on implementing this? If no, I'll take a crack

[Haskell-cafe] ANNOUNCE: Dimensional 0.6 -- Statically checked physical dimensions

2007-08-02 Thread Björn Buckwalter
Dear all, I am pleased to announce version 0.6 of the Dimensional library. Dimensional is a library providing data types for performing arithmetic with physical quantities and units. Information about the physical dimensions of the quantities/units is embedded in their types and the validity

Re: RE [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-02 Thread Dan Weston
Ok, I am guessing that if you were Neo in The Matrix, you would have taken the Blue Pill. Blue Pill people ask How. I suspect most people attracted to Haskell have already taken the Red Pill. Red Pill people ask Why. It is compulsion, not self-interest, that drives Red Pill people to look

Re: [Haskell-cafe] positive Int

2007-08-02 Thread David Roundy
On Thu, Aug 02, 2007 at 12:29:46PM -0700, brad clawsie wrote: On Thu, Aug 02, 2007 at 12:17:06PM -0700, brad clawsie wrote: as far as i know, the haskell standard does not define a basic Int type that is limited to positive numbers. would a type of this kind not potentially allow us to

Re: [Haskell-cafe] positive Int

2007-08-02 Thread Michael Vanier
Of course, you can always do this: data Nat = Zero | Succ Nat but it's not very much fun to work with, and not very efficient. Mike David Roundy wrote: On Thu, Aug 02, 2007 at 12:29:46PM -0700, brad clawsie wrote: On Thu, Aug 02, 2007 at 12:17:06PM -0700, brad clawsie wrote: as far as i

Re: [Haskell-cafe] Primitive Recursive Algebraic Types

2007-08-02 Thread Nicolas Frisby
It seems you are confusing the notion of counting the number of operators in the expression with actually evaluating the expression. Your evalLength function does both. It may help to consider counting the number of operators in the expression to be the same as calculating the height of the

Re: [Haskell-cafe] positive Int

2007-08-02 Thread Lauri Alanko
On Thu, Aug 02, 2007 at 02:08:33PM -0700, David Roundy wrote: This would be a very nice type to have (natural numbers), but is a tricky type to work with. Subtraction, for instance, wouldn't be possible as a complete function... Of course it would. It would just have the type Nat - Nat -

Re: [Haskell-cafe] ANNOUNCE: Dimensional 0.6 -- Statically checked physical dimensions

2007-08-02 Thread David Roundy
On Thu, Aug 02, 2007 at 10:27:47PM +0200, Björn Buckwalter wrote: I am also assuming that the CGS system would not be employed when working with temperature, amount or luminosity. This is evident in the below type signatures where I have assumed zero extent in the temperature, amount and

Re: [Haskell-cafe] monad subexpressions

2007-08-02 Thread Dan Licata
Hi Chris, Simon mentioned this to me as a possible project when I started my internship here at MSR, so I'm pretty sure this is both on the wish-list and not already taken (but we should check with Simon to make sure). I've since wished for it a few times as I've been implementing view patterns,

Re: [Haskell-cafe] positive Int

2007-08-02 Thread Ian Lynagh
On Thu, Aug 02, 2007 at 12:17:06PM -0700, brad clawsie wrote: as far as i know, the haskell standard does not define a basic Int type that is limited to positive numbers. Haskell 98 doesn't have such a type, no, but in today's libraries there is Data.Word.Word. Operations like subtraction will

Re: RE [Haskell-cafe] Monad Description For Imperative

2007-08-02 Thread ok
I wrote: But please, let's keep one foot in the real world if possible. Monads were invented to solve the how do I do imperative programming in a pure functional language problem. On 2 Aug 2007, at 7:05 pm, Greg Meredith wrote: This is more than a little revisionist. Monads have been the

Re: [Haskell-cafe] ANNOUNCE: Dimensional 0.6 -- Statically checked physical dimensions

2007-08-02 Thread Björn Buckwalter
David Roundy wrote: On Thu, Aug 02, 2007 at 10:27:47PM +0200, Björn Buckwalter wrote: I am also assuming that the CGS system would not be employed when working with temperature, amount or luminosity. This is evident in the below type signatures where I have assumed zero extent in the

Re: RE [Haskell-cafe] Monad Description For Imperative

2007-08-02 Thread Dan Piponi
ok wrote: It is considerably more than a little revisionist to identify Haskell monads with Category Theory monads. So a category theory monad is a functor from some category to itself. How is IO a a functor? Which category does it operate on? What does it do to the points of that

Re: RE [Haskell-cafe] Monad Description For Imperative

2007-08-02 Thread Dan Weston
My category theory is pretty weak, but I'll take a stab (others can correct me if I say something stupid): ok wrote: It is considerably more than a little revisionist to identify Haskell monads with Category Theory monads. Quoting the Wikipedia article on monads: If F and G are a pair of

Re: [Haskell-cafe] positive Int

2007-08-02 Thread David Menendez
On 8/2/07, David Roundy [EMAIL PROTECTED] wrote: This would be a very nice type to have (natural numbers), but is a tricky type to work with. Subtraction, for instance, wouldn't be possible as a complete function... There is a subtraction-like operation for naturals, where a - b = 0 if a = b.

Re: [Haskell-cafe] positive Int

2007-08-02 Thread Stefan O'Rear
On Fri, Aug 03, 2007 at 01:45:03AM +0100, Neil Mitchell wrote: Hi Catch (www.cs.york.ac.uk/~ndm/catch) can infer that certain uses of numbers fit into the {Neg, Zero, One, Pos} abstraction - so for example it can infer that length returns {Zero, One, Pos}, but not Neg. If you then do: xs

Re: [Haskell-cafe] positive Int

2007-08-02 Thread Neil Mitchell
Hi Catch (www.cs.york.ac.uk/~ndm/catch) can infer that certain uses of numbers fit into the {Neg, Zero, One, Pos} abstraction - so for example it can infer that length returns {Zero, One, Pos}, but not Neg. If you then do: xs !! length ys It will detect that length ys is natural, and will be

Re: [Haskell-cafe] Perfect example

2007-08-02 Thread Neil Mitchell
Hi I know that Audrey Tang (the Pugs project) has used hamming numbers for this, see http://www.perl.com/lpt/a/959 Thanks Neil On 8/2/07, Jon Harrop [EMAIL PROTECTED] wrote: Any suggestions for a perfect example that uniquely demonstrates the benefits of the Haskell language compared to

Re: [Haskell-cafe] monad subexpressions

2007-08-02 Thread Neil Mitchell
Hi Chris, I've heard Simon (Peyton-Jones) twice now mention the desire to be able to embed a monadic subexpression into a monad. I think this is a fantastic idea, please do so! $( expr ) -- conflicts with template haskell ( - expr ) -- makes sense, and I think it's unambiguous

Re: [Haskell-cafe] Perfect example

2007-08-02 Thread Bernie Pope
That's a tough one, If I want a small example to show to people I usually use zipWith. It is higher-order and lazy, and I include a discussion of lists as loops, which means zipWith is a loop combiner. When my audience is C programmers I ask them to implement it in C, which is always

Re: [Haskell-cafe] positive Int

2007-08-02 Thread Neil Mitchell
Hi It will detect that length ys is natural, and will be safe. However, if you pass any arbitrary value as the index to !! it will warn of a possible pattern match error. I hope catch doesn't actually think that's safe, because it's not - set ys = xs = [1,2,3,4,5], you'll get an index

Re: RE [Haskell-cafe] Monad Description For Imperative

2007-08-02 Thread ok
I asked How is IO a functor? On 3 Aug 2007, at 11:50 am, Dan Piponi wrote: IO is a fully paid up Monad in the categorical sense. The category is the category whose objects are types and whose arrows are functions between those types. IO is a functor. The object a maps to IO a. An arrow f::a-b

Re: RE [Haskell-cafe] Monad Description For Imperative

2007-08-02 Thread Dan Piponi
On 8/2/07, ok [EMAIL PROTECTED] wrote: I asked How is IO a functor? Please go over this again, but slowly this time. Try it... by golly it's true. I'm not fibbing. I was surprised as you when I found out about this stuff! So why *aren't* Monads already set up using the type class machinery

Re: [Haskell-cafe] GHC, GLUT and OS X

2007-08-02 Thread Paul L
Ok, after spending some time looking for a solution, here is a stroke of genius by wxHaskell folks at http://wxhaskell.sourceforge.net/building-macosx.html I've tried this enableGUI trick using GHCi, it works with my GLFW interface to Haskell which suffered from the same problem as GLUT on OS X,

Re: [Haskell-cafe] Re: monad subexpressions

2007-08-02 Thread Derek Elkins
On Thu, 2007-08-02 at 21:29 -0600, Chris Smith wrote: Neil Mitchell [EMAIL PROTECTED] wrote: I think this is a fantastic idea, please do so! Okay, I'll do it then. If I have a good weekend, perhaps I'll volunteer a talk at AngloHaskell after all! :) So what about syntax? I agree

Re: [Haskell-cafe] When is waitForProcess not necessary?

2007-08-02 Thread Donald Bruce Stewart
bayer: If one is calling runInteractiveCommand for a sure-thing returning a small amount of output (say, ls for a modest directory), is it necessary to call waitForProcess? My waitForProcess calls came under scrutiny when I tried to GHC profile a threaded process, which isn't possible. It

[Haskell-cafe] Re: monad subexpressions

2007-08-02 Thread Chris Smith
Neil Mitchell [EMAIL PROTECTED] wrote: I think this is a fantastic idea, please do so! Okay, I'll do it then. If I have a good weekend, perhaps I'll volunteer a talk at AngloHaskell after all! :) So what about syntax? I agree with your objections, so we've got ( - expr ) -- makes

[Haskell-cafe] Re: Re: monad subexpressions

2007-08-02 Thread Chris Smith
Derek Elkins [EMAIL PROTECTED] wrote: ( - expr ) -- makes sense, and I think it's unambiguous ``expr`` -- back-ticks make sense for UNIX shell scripters The latter is not sensible to me at all. It doesn't nest well. Ah, excellent point! Okay, it's gone then. Everything will then

Re: [Haskell-cafe] Perfect example

2007-08-02 Thread Bulat Ziganshin
Hello Jon, Thursday, August 2, 2007, 11:02:14 PM, you wrote: Any suggestions for a perfect example that uniquely demonstrates the benefits of the Haskell language compared to other languages? http://www.haskell.org/haskellwiki/Simple_unix_tools -- Best regards, Bulat