Re: [Haskell-cafe] Re: A free monad theorem?

2006-09-03 Thread Tomasz Zielonka
On Sun, Sep 03, 2006 at 01:23:13AM +0200, [EMAIL PROTECTED] wrote: Tomasz Zielonka: Programmers define the = method for their monads because they want to use it to bind computations. They know how to pass result(s) from one computation in their Monad to another, and they put this algorithm

[Haskell-cafe] practice problems?

2006-09-03 Thread Tamas K Papp
Hi, I am a Haskell newbie. Having read some tutorials (Yet Another, Gentle Introduction) and some papers/tutorials on monads, I would like to spend some time practicing what I have learned before embarking on more abstract/obscure things and/or using Haskell for everyday tasks. I am looking for

Re[2]: [Haskell-cafe] Are associated types synonyms like type classes?

2006-09-03 Thread Bulat Ziganshin
Hello Brian, Saturday, September 2, 2006, 10:19:17 PM, you wrote: What is the practical difference between class A and class B? With class A we can define instances so that f is overloaded (Int - Bool), (String - Bool), (Bool - Bool) by defining instances of A for Int, String, and Bool, but

Re: [Haskell-cafe] practice problems?

2006-09-03 Thread Bulat Ziganshin
Hello Tamas, Sunday, September 3, 2006, 12:15:48 PM, you wrote: I am looking for small to medium sized practice problems, preferably with solutions. Hal Daume's tutorial had some good one-liners (eg rewrite something point-free) but I am looking for something which would take 1-3 hours for

Re: [Haskell-cafe] practice problems?

2006-09-03 Thread Tamas K Papp
On Sun, Sep 03, 2006 at 12:47:45PM +0400, Bulat Ziganshin wrote: Hello Tamas, Sunday, September 3, 2006, 12:15:48 PM, you wrote: I am looking for small to medium sized practice problems, preferably with solutions. Hal Daume's tutorial had some good one-liners (eg rewrite something

Re: [Haskell-cafe] practice problems?

2006-09-03 Thread Brian Hulley
Tamas K Papp wrote: On Sun, Sep 03, 2006 at 12:47:45PM +0400, Bulat Ziganshin wrote: i also suggest you to start write some library. there is enough useful libs that are still bnot implemented because lack of time (and insterest in such simple code) on side of more experienced programmers. i

Re: [Haskell-cafe] practice problems?

2006-09-03 Thread Brian Hulley
Brian Hulley wrote: Interval llow lhigh + Interval rlow rhigh = Interval (min llow rlow) (max lhigh rhigh) Not a good start!!! ;-) Interval llow lhigh + Interval rlow rhigh = Interval (llow+rlow) (lhigh+rhigh) ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] Re: Re: A free monad theorem?

2006-09-03 Thread Lennart Augustsson
Well, bind is extracting an 'a'. I clearly see a '\ a - ...'; it getting an 'a' so it can give that to g. Granted, the extraction is very convoluted, but it's there. -- Lennart On Sep 2, 2006, at 19:44 , Udo Stenzel wrote: Benjamin Franksen wrote: Sure. Your definition of bind

Re: [Haskell-cafe] practice problems?

2006-09-03 Thread Jan-Willem Maessen
On Sep 3, 2006, at 8:22 AM, Brian Hulley wrote: Tamas K Papp wrote: On Sun, Sep 03, 2006 at 12:47:45PM +0400, Bulat Ziganshin wrote: i also suggest you to start write some library. there is enough useful libs that are still bnot implemented because lack of time (and insterest in such

Re: [Haskell-cafe] Re: Re: A free monad theorem?

2006-09-03 Thread Daniel Fischer
Am Sonntag, 3. September 2006 15:39 schrieb Lennart Augustsson: Well, bind is extracting an 'a'. I clearly see a '\ a - ...'; it getting an 'a' so it can give that to g. Granted, the extraction is very convoluted, but it's there. -- Lennart But instance Monad (Cont r) where

Re: [Haskell-cafe] Re: Re: A free monad theorem?

2006-09-03 Thread Udo Stenzel
Lennart Augustsson wrote: Well, bind is extracting an 'a'. I clearly see a '\ a - ...'; it getting an 'a' so it can give that to g. Granted, the extraction is very convoluted, but it's there. Oh, that can be remedied... m = g = m . flip g In fact, why even mention m? (=) = (. flip)

Re: [Haskell-cafe] practice problems?

2006-09-03 Thread Paul Johnson
Brian Hulley [EMAIL PROTECTED] wrote: What about a library for interval arithmetic [1]? I'd imagine it could start something like: data Interval a = Interval !a !a deriving (Eq, Show) instance Num a = Num (Interval a) where Interval llow lhigh + Interval rlow rhigh = Interval

[Haskell-cafe] beginner's problam with a monad

2006-09-03 Thread Julien Oster
Hello, after succeeding in implementing my first monad (Counter, it increments a counter every time a computation is performed) I though I'd try another one and went on to implement Tracker. Tracker is a monad where a list consisting of the result of every computation is kept alongside the final

Re: [Haskell-cafe] beginner's problam with a monad

2006-09-03 Thread Dan Doel
On 9/3/06, Julien Oster [EMAIL PROTECTED] wrote: Hello, Hi. Why does the interpreter infer Tracker a a instead of the more general Tracker a c? The problem is that you're trying to keep a list of all computations performed, and lists can only store values of one uniform type. So, if you

Re: [Haskell-cafe] beginner's problam with a monad

2006-09-03 Thread Julien Oster
Dan Doel wrote: Thus, unfortunately, you won't be able to implement the general bind operator. To do so, you'd need to have Tracker use a list that can store values of heterogeneous types, which is an entire library unto itself (HList). Telling me that it just won't work was one of the best

Re: [Haskell-cafe] beginner's problam with a monad

2006-09-03 Thread Keegan McAllister
Now if anyone could enlighten me about the instance Monad Tracker a instead of instance Monad Tracker part, everything will be clear! A Monad always takes one type argument -- the a in IO a, Maybe a, etc. So Tracker can't be a Monad (it needs two arguments), but (Tracker a) is, for any a.

[Haskell-cafe] Problems trying to understand the BSD license

2006-09-03 Thread Brian Hulley
Hi - I'm not sure if this is the right place to ask this question but since a lot of Haskell code is under the BSD license I think the answer could be useful for other people as well. The question I have is if I want to redistribute a binary executable under my own proprietary license that

[Haskell-cafe] Re: beginner's problam with a monad

2006-09-03 Thread Benjamin Franksen
Julien Oster wrote: Now if anyone could enlighten me about the instance Monad Tracker a instead of instance Monad Tracker part, everything will be clear! Hello Julien, The way you defined it, Tracker is a type constructor with two arguments, both of which are types; another way to state this

Re: [Haskell-cafe] Re: beginner's problam with a monad

2006-09-03 Thread Julien Oster
Benjamin Franksen wrote: Partially applying Tracker to one argument ('T a') gives you a type constructor that has only one remaining 'open' argument and thus can be made an instance of class Monad. Totally clear, thanks a lot (also to Keegan). Julien

Re: [Haskell-cafe] practice problems?

2006-09-03 Thread Brian Hulley
Paul Johnson wrote: Brian Hulley [EMAIL PROTECTED] wrote: What about a library for interval arithmetic [1]? [Interval 5 5] / [Interval -1 1] = [FromNegInfinityTo -5, ToPosInfinityFrom 5] Take a look at my Ranged Sets library at http://sourceforge.net/projects/ranged-sets Hi Paul

[Haskell-cafe] Advantages of using qualified names and a uniform naming convention

2006-09-03 Thread Brian Hulley
Hi - There's lots of great Haskell libraries available, but little standardization regarding naming conventions or code organization. In this post I try to illustrate some dimensions of the question of how to form names for things and offer my opinion on specific examples knowing that this of

Re: [Haskell-cafe] A free monad theorem?

2006-09-03 Thread ajb
G'day all. Quoting Benjamin Franksen [EMAIL PROTECTED]: As we all know, the monadic bind operation has type: bind :: Monad m = m a - (a - m b) - m b My intuition says that in order to apply the second argument to some non-trivial (i.e. non-bottom) value of type a, the bind operator

Re: [Haskell-cafe] Re: Re: A free monad theorem?

2006-09-03 Thread Lennart Augustsson
You are right, but I was using extraction in a rather non-technical sense. Look at it this way: we have 'x = f', let's assume it's the continuation monad. Assuming f has type 'a - C b' we must have something of type a to be able to call the function be at all. Somehow = is able make sure