Re: [Haskell-cafe] reifying typeclasses

2013-09-17 Thread Evan Laforge
a I guess what you're saying is that since I'm implementing a typeswitch, then I lose the nice feature of typeclasses that I know it can't do anything with the value except what the typeclass provides. In a sense, it loses type safety because it's too generic. That's a good point too. No free

Re: [Haskell-cafe] reifying typeclasses

2013-09-17 Thread oleg
I've been toying with using Data Types a la Carte to get type representations, a `Typeable` class and dynamic types parameterized by a possibly open universe: If the universe is potentially open, and if we don't care about exhaustive pattern-matching check (which is one of the principal

Re: [Haskell-cafe] reifying typeclasses

2013-09-16 Thread Emil Axelsson
2013-09-15 11:16, o...@okmij.org skrev: Evan Laforge wrote: I have a typeclass which is instantiated across a closed set of 3 types. It has an ad-hoc set of methods, and I'm not too happy with them because being a typeclass forces them to all be defined in one place, breaking modularity. A

reifying typeclasses (resend)

2013-09-15 Thread Evan Laforge
not enough power to express what typeclasses give you. Also it seems like there's a fundamental difference between dispatching on argument vs dispatching on result. Is there a way to more formally understand the extents of what typeclasses provide, and what a toTagged fromTagged scheme gives me, so I can

Re: [Haskell-cafe] reifying typeclasses (resend)

2013-09-15 Thread Timon Gehr
val TypeChar = toEnum val So, perhaps my intuition was wrong. toTagged and fromTagged methods give you the power to go between value and type level, but apparently that's not enough power to express what typeclasses give you. You do get enough power to write that second function

Re: [Haskell-cafe] reifying typeclasses

2013-09-15 Thread oleg
Evan Laforge wrote: I have a typeclass which is instantiated across a closed set of 3 types. It has an ad-hoc set of methods, and I'm not too happy with them because being a typeclass forces them to all be defined in one place, breaking modularity. A sum type, of course, wouldn't have that

Re: [Haskell-cafe] reifying typeclasses (resend)

2013-09-15 Thread Bas van Dijk
. toTagged and fromTagged methods give you the power to go between value and type level, but apparently that's not enough power to express what typeclasses give you. Also it seems like there's a fundamental difference between dispatching on argument vs dispatching on result. Is there a way to more

Re: [Haskell-cafe] reifying typeclasses

2013-09-15 Thread oleg
[I too had the problem sending this e-mail to Haskell list. I got a reply saying the message awaits moderator approval] Evan Laforge wrote: I have a typeclass which is instantiated across a closed set of 3 types. It has an ad-hoc set of methods, and I'm not too happy with them because being

[Haskell-cafe] IO typeclasses

2011-12-29 Thread David Thomas
Is there any particular reason IO functions in the standard libraries aren't grouped into type-classes? This might allow for: 1) Testing IO code without actual input and output. (I have done this on a small scale, but it presently involves much ugliness). 2) Redirecting output of a function that

Re: [Haskell-cafe] IO typeclasses

2011-12-29 Thread Chris Wong
On Fri, Dec 30, 2011 at 4:47 PM, David Thomas davidleotho...@gmail.com wrote: Is there any particular reason IO functions in the standard libraries aren't grouped into type-classes? I'm guessing it's to stop the report from getting too complicated. If you want an IO abstraction, you can try

[Haskell-cafe] Typeclasses, data, constructors

2011-07-27 Thread Sergiy Nazarenko
enjoy it. But now I want to get rows, and I don't know what to do :( I want func something like this: getRow :: Int - [MyTable] - what should I write here ? Possibly use this function: getRow 23 :: MyTableTwo (like haskell function Read for example: read 7 :: Int) I try to use typeclasses

Re: [Haskell-cafe] Typeclasses, data, constructors

2011-07-27 Thread Joachim Fasting
On 27 July 2011 10:45, Sergiy Nazarenko nazarenko.ser...@gmail.com wrote: Hi everyone! Hi, I have data declaration like this: I try to use typeclasses, class GetRow a where    hasID :: Int - IO a instance GetRow MyTableOne where    hasID myid = return [(MyTableOne 1 name)] instance GetRow

Re: [Haskell-cafe] Random thoughts about typeclasses

2011-05-18 Thread Dominique Devriese
Robert, 2011/5/16 Robert Clausecker fuz...@gmail.com: I found out, that GHC implements typeclasses as an extra argument, a record that stores all functions of the typeclass. So I was wondering, is there a way (apart from using newtype) to pass a custom record as the typeclass record

[Haskell-cafe] Random thoughts about typeclasses

2011-05-16 Thread Robert Clausecker
Hello! I found out, that GHC implements typeclasses as an extra argument, a record that stores all functions of the typeclass. So I was wondering, is there a way (apart from using newtype) to pass a custom record as the typeclass record, to modify the behavior of the typeclass? I thought about

Re: [Haskell-cafe] Random thoughts about typeclasses

2011-05-16 Thread Ertugrul Soeylemez
Robert Clausecker fuz...@gmail.com wrote: I found out, that GHC implements typeclasses as an extra argument, a record that stores all functions of the typeclass. So I was wondering, is there a way (apart from using newtype) to pass a custom record as the typeclass record, to modify

Re: [Haskell-cafe] Random thoughts about typeclasses

2011-05-16 Thread Casey McCann
On Mon, May 16, 2011 at 8:10 AM, Robert Clausecker fuz...@gmail.com wrote: I found out, that GHC implements typeclasses as an extra argument, a record that stores all functions of the typeclass. So I was wondering, is there a way (apart from using newtype) to pass a custom record

[Haskell-cafe] Typeclasses question in Real World Haskell book

2010-07-26 Thread Angel de Vicente
Hi, I'm stuck at page 151 of Real World Haskell and hoping that perhaps some of you can give me a hand here... The code that is giving me trouble is below. data JValue = JString String | JNumber Double | JBool Bool | JNull | JObject [(String,

Re: [Haskell-cafe] Typeclasses question in Real World Haskell book

2010-07-26 Thread S. Doaitse Swierstra
How about: *Main fromJValue (JBool True) :: Either JSONError Bool Right True *Main Doaitse On 26 jul 2010, at 15:16, Angel de Vicente wrote: data JValue = JString String | JNumber Double | JBool Bool | JNull | JObject [(String, JValue)]

Re: [Haskell-cafe] Typeclasses question in Real World Haskell book

2010-07-26 Thread Daniel Fischer
On Monday 26 July 2010 15:16:36, Angel de Vicente wrote: Hi, I'm stuck at page 151 of Real World Haskell and hoping that perhaps some of you can give me a hand here... The code that is giving me trouble is below. data JValue = JString String | JNumber Double |

Re: [Haskell-cafe] Typeclasses question in Real World Haskell book

2010-07-26 Thread Angel de Vicente
Hi, thanks for the answer. This is my first attempt at Typeclasses, and I think there is something deep that I don't understand... On 26/07/10 15:03, Daniel Fischer wrote: class JSON a where toJValue :: a - JValue fromJValue :: JValue - Either JSONError a instance JSON JValue

Re: [Haskell-cafe] Typeclasses question in Real World Haskell book

2010-07-26 Thread Daniel Fischer
On Monday 26 July 2010 21:03:10, Angel de Vicente wrote: Hi, thanks for the answer. This is my first attempt at Typeclasses, and I think there is something deep that I don't understand... On 26/07/10 15:03, Daniel Fischer wrote: class JSON a where toJValue :: a - JValue

Re: [Haskell-cafe] Typeclasses question in Real World Haskell book

2010-07-26 Thread Angel de Vicente
Hi, And now that we are at it... In the next page, 152 there is the following instance definition, but no explanation is (I think) given of what it means: instance (JSON a) = JSON [a] where until then all instance definitions where of the type instance JSON Int where ... How should I read

Re: [Haskell-cafe] Typeclasses question in Real World Haskell book

2010-07-26 Thread Richard O'Keefe
On Jul 27, 2010, at 1:16 AM, Angel de Vicente wrote: data JValue = JString String | JNumber Double | JBool Bool | JNull | JObject [(String, JValue)] | JArray [JValue] deriving (Eq, Ord, Show) type JSONError = String

[Haskell-cafe] Preconditions as Typeclasses (Was: Re: Mysterious factorial)

2009-12-30 Thread Luke Palmer
: the operator you're giving it has to be associative.  I like to use typeclasses to express laws. That's a valid point. Unfortunately, Haskell is not Coq, so there is no guarantee that the monoid laws are actually satisfied. And using a type-class has the downside that you can have only one instance

[Haskell-cafe] Typeclasses for name punning (was: Re: I miss OO)

2009-11-27 Thread Daniel Schüssler
, then a type class is how you capture that. It sounds like you do have this structure in your example. Further, with typeclasses, you can write methods that are generic over any type with that structure. So: class Temporal a where time :: a - Time temporalOrder :: Temporal

Re: [Haskell-cafe] Typeclasses for name punning (was: Re: I miss OO)

2009-11-27 Thread David Virebayre
2009/11/27 Daniel Schüssler anotheraddr...@gmx.de I think punning is a worthwhile goal on its own, since I find myself wasting quite some thought on whether to prefix a record field name somehow, and if I do, what I should use as a short but sufficiently unique prefix. I agree, especially

Re: [Haskell-cafe] Problem with result-type context restrictions in typeclasses.

2009-09-30 Thread Miguel Mitrofanov
class Cls c where type Ret c :: (Bar *) = * -- or a better name foo :: c - Ret c which isn't legal Haskell. OK, that's exactly the same thing I've met when developing compose-trans. I needed guarantees that something is a Monad. My way of doing that was to make Bar (Monad in my case)

Re: Re: [Haskell-cafe] Problem with result-type context restrictions in typeclasses.

2009-09-30 Thread Ryan Ingram
foo = fuu That should work (although I haven't tested it). What type families do in this case is allow you to write not only methods associated with typeclasses, but type functions associated with them too. In this case you can think of Ret as a function that takes a type (G

Re: Re: [Haskell-cafe] Problem with result-type context restrictions in typeclasses.

2009-09-30 Thread Alexander Dunlap
Ret c :: * -- or a better name    foo :: c - Ret c instance Cls G where    type Ret G = FU    foo = fuu That should work (although I haven't tested it). What type families do in this case is allow you to write not only methods associated with typeclasses, but type functions associated

[Haskell-cafe] Problem with result-type context restrictions in typeclasses.

2009-09-29 Thread DNM
N.B. I'm a newbie to Haskell, and this problem is a bit complex, so bear with me. I'm using typeclasses to implement a sort of common interface for all things -- call them things of type 'Cls' -- that can be expected to implement a set of functions -- an 'interface' in OOP-speak. (Yes, yes, I'm

[Haskell-cafe] Re: Problem with result-type context restrictions in typeclasses.

2009-09-29 Thread DNM
dnme...@gmail.com wrote: N.B. I'm a newbie to Haskell, and this problem is a bit complex, so bear with me. I'm using typeclasses to implement a sort of common interface for all things -- call them things of type 'Cls' -- that can be expected to implement a set of functions -- an 'interface

Re: [Haskell-cafe] Re: Problem with result-type context restrictions in typeclasses.

2009-09-29 Thread Daniel Peebles
haven't tested it). What type families do in this case is allow you to write not only methods associated with typeclasses, but type functions associated with them too. In this case you can think of Ret as a function that takes a type (G in the instance above) and returns another type (FU). Each

Re: Re: [Haskell-cafe] Problem with result-type context restrictions in typeclasses.

2009-09-29 Thread DNM
it). What type families do in this case is allow you to write not only methods associated with typeclasses, but type functions associated with them too. In this case you can think of Ret as a function that takes a type (G in the instance above) and returns another type (FU). Each instance can define

[Haskell-cafe] Typeclasses vs simple functions?

2009-09-15 Thread Olex P
perimeters of each object using map perimerer list (in this case we also have to modify Geometry data type). So we could make instances of perimeter type class for all objects and return zero in case if perimeter doesn't make sense. Same as previous version but with typeclasses and with additional

Re: [Haskell-cafe] Typeclasses vs simple functions?

2009-09-15 Thread Olex P
type class for all objects and return zero in case if perimeter doesn't make sense. Same as previous version but with typeclasses and with additional constructors (constructors for each type of object + constructors in Geometry data). Looks a bit overcomplicated. Any reasons to use type

Re: [Haskell-cafe] Typeclasses vs simple functions?

2009-09-15 Thread Olex P
make instances of perimeter type class for all objects and return zero in case if perimeter doesn't make sense. Same as previous version but with typeclasses and with additional constructors (constructors for each type of object + constructors in Geometry data). Looks a bit overcomplicated

[Haskell-cafe] Typeclasses vs simple functions?

2009-09-15 Thread Lyndon Maydwell
-- Forwarded message -- From: Lyndon Maydwell maydw...@gmail.com Date: Tue, Sep 15, 2009 at 10:03 PM Subject: Re: [Haskell-cafe] Typeclasses vs simple functions? To: Olex P hoknam...@gmail.com I think it depends on what is going to be using the functions, data. As far as I can

Re: [Haskell-cafe] Typeclasses vs simple functions?

2009-09-15 Thread John Dorsey
perimeter :: Geometry - Double perimeter (Sphere _ r) = 0.0 perimeter (Circle _ r) = 2.0 * pi * r The latter is even simpler because there is no need in extraction of Double value from Maybe. I'd strongly advise against this last one on style grounds. (0 :: Double) isn't nearly as

Re: [Haskell-cafe] Typeclasses vs simple functions?

2009-09-15 Thread Sean Leather
make sense. Same as previous version but with typeclasses and with additional constructors (constructors for each type of object + constructors in Geometry data). Looks a bit overcomplicated. Any reasons to use type classes in this case? Maybe there is something I'm missing? If you're talking

Re: [Haskell-cafe] Typeclasses vs simple functions?

2009-09-15 Thread Olex P
using map perimerer list (in this case we also have to modify Geometry data type). So we could make instances of perimeter type class for all objects and return zero in case if perimeter doesn't make sense. Same as previous version but with typeclasses and with additional constructors

Re: [Haskell-cafe] Typeclasses vs simple functions?

2009-09-15 Thread Tom Nielsen
but with typeclasses and with additional constructors (constructors for each type of object + constructors in Geometry data). Looks a bit overcomplicated. Any reasons to use type classes in this case? Maybe there is something I'm missing? Cheers, -O ___ Haskell

Re: [Haskell-cafe] Typeclasses vs simple functions?

2009-09-15 Thread Olex P
and return zero in case if perimeter doesn't make sense. Same as previous version but with typeclasses and with additional constructors (constructors for each type of object + constructors in Geometry data). Looks a bit overcomplicated. Any reasons to use type classes in this case? Maybe

Re: [Haskell-cafe] Typeclasses vs simple functions?

2009-09-15 Thread Sean Leather
Existential types sounds a bit scary :) It's unfortunate that they've developed a scariness feeling associated with them. They can be used in strange ways, but simple uses are quite approachable. One way to think of them is like implementing an object-oriented interface. You know it's an

Re: [Haskell-cafe] Typeclasses vs simple functions?

2009-09-15 Thread Olex P
Thanks for explanation Sean! On Tue, Sep 15, 2009 at 4:30 PM, Sean Leather leat...@cs.uu.nl wrote: Existential types sounds a bit scary :) It's unfortunate that they've developed a scariness feeling associated with them. They can be used in strange ways, but simple uses are quite

[Haskell-cafe] Functional Dependencies and multiparameter typeclasses

2009-08-24 Thread Harald ROTTER
Dear Haskellers, I am using multi parameter typeclasses to represent images consisting of pixels (e.g. bitmap images). {-# OPTIONS_GHC -XMultiParamTypeClasses #-} module Bitmap where -- | a pixel could be a Word8 (e.g. a graysclale image) -- | or a 3-tuple for RGB images

Re: [Haskell-cafe] Functional Dependencies and multiparameter typeclasses

2009-08-24 Thread Miguel Mitrofanov
However, I do not really understand the cause of the original problem. Why do I need the functional dependency to make this work ? Suppose you have an instance: instance Pixel MyPixel where... instance Image MyImage MyPixel where width i = countPixels i ... And somebody (not necessarily

Re: [Haskell-cafe] Functional Dependencies and multiparameter typeclasses

2009-08-24 Thread Bulat Ziganshin
Hello Harald, Monday, August 24, 2009, 3:17:28 PM, you wrote: class Pixel p where -- | an image could be a UArray or a list of lists of pixels class Pixel p = Image a p where read http://haskell.org/haskellwiki/OOP_vs_type_classes here you say that Image is a particular

[Haskell-cafe] typeclasses comprehension problems: situation classes?

2009-05-16 Thread Belka
Hello, cafe visitors! I'm trying to learn Haskell typeclasses, - about how to use them, - but can't handle some conceptiual problems, which confuses me a lot. I took one real problem (ErrorInfo gragual gathering), to tackle it in my studies: I have a class of situations: there is an object

Re: [Haskell-cafe] typeclasses comprehension problems: situation classes?

2009-05-16 Thread Bulat Ziganshin
Hello Belka, Saturday, May 16, 2009, 9:22:54 PM, you wrote: I'm trying to learn Haskell typeclasses, - about how to use them, - but am i correctly understood that you've started learning type classes with multi-parameter ones? this may be a bit too brave, especially for a woman :D i suggest

Re: [Haskell-cafe] typeclasses comprehension problems: situation classes?

2009-05-16 Thread Magnus Therning
Bulat Ziganshin wrote: Hello Belka, Saturday, May 16, 2009, 9:22:54 PM, you wrote: I'm trying to learn Haskell typeclasses, - about how to use them, - but am i correctly understood that you've started learning type classes with multi-parameter ones? this may be a bit too brave, especially

[Haskell-cafe] Haskell/JS -- better through typeclasses?

2009-04-26 Thread Dimitry Golubovsky
Jason and everybody interested, Please check out a package I recently (just by coincidence: I haven't seen this topic on the list until after I uploaded it) uploaded to Hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/jsmw-0.1 This is a basic monadic interface to Javascript

Re: [Haskell-cafe] Haskell/JS -- better through typeclasses?

2009-04-26 Thread John A. De Goes
I can't speak for Jason, but for me, this is not very useful. I don't want to write in a Haskell DSL, I want to write in Haskell. And not the whole program, either, just the parts that really lend themselves to functional programming (parsers, numeric computations, code generators,

Re: [Haskell-cafe] Haskell/JS -- better through typeclasses?

2009-04-26 Thread Jason Dusek
2009/04/26 John A. De Goes j...@n-brain.net: I can't speak for Jason, but for me, this is not very useful. I don't want to write in a Haskell DSL, I want to write in Haskell. And not the whole program, either, just the parts that really lend themselves to functional programming (parsers,

Re: [Haskell-cafe] Haskell/JS -- better through typeclasses?

2009-04-26 Thread John A. De Goes
On Apr 26, 2009, at 10:18 AM, Jason Dusek wrote: This was what I was originally writing in about, yeah. However, thinking it over I realize there are some serious problems. We really do want to work with a restricted subset of Haskell that is more amenable to translation -- one with finite

[Haskell-cafe] Haskell/JS -- better through typeclasses?

2009-04-26 Thread Dimitry Golubovsky
John wrote: I can't speak for Jason, but for me, this is not very useful. I don't want to write in a Haskell DSL, I want to write in Haskell. And not the whole program, either, just the parts that really lend themselves to functional programming (parsers, numeric computations, code

Re: [Haskell-cafe] Haskell/JS -- better through typeclasses?

2009-04-26 Thread Jason Dusek
2009/04/26 John A. De Goes j...@n-brain.net: 2009/04/26 Jason Dusek:  This was what I was originally writing in about, yeah.  However, thinking it over I realize there are some serious  problems. We really do want to work with a restricted subset  of Haskell that is more amenable to translation

Re: [Haskell-cafe] Haskell/JS -- better through typeclasses?

2009-04-26 Thread Jason Dusek
2009/04/26 Dimitry Golubovsky golubov...@gmail.com: John wrote: I can't speak for Jason, but for me, this is not very useful. I don't want to write in a Haskell DSL, I want to write in Haskell. And not the whole program, either, just the parts that really lend themselves to functional

[Haskell-cafe] Re: Haskell/JS -- better through typeclasses?

2009-04-26 Thread Stefan Monnier
There's a tool for converting SML to JavaScript: Such tools converting between different languages, are usually called compilers, by the way. Stefan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

[Haskell-cafe] Haskell/JS -- better through typeclasses?

2009-04-25 Thread Jason Dusek
I'd like to be able to translate Haskell to JavaScript. Many Haskell/JS bridges provide libraries for writing complete JavaScript programs in Haskell; some of them even include jQuery. However, my goals are more limited -- I'd like to be able to take a Haskell module and turn it into a

Re: [Haskell-cafe] Haskell/JS -- better through typeclasses?

2009-04-25 Thread Miguel Mitrofanov
On 25 Apr 2009, at 21:53, Jason Dusek wrote: Many Haskell/JS bridges provide libraries for writing complete JavaScript programs in Haskell; some of them even include jQuery. However, my goals are more limited -- I'd like to be able to take a Haskell module and turn it into a JavaScript

Re: [Haskell-cafe] Haskell/JS -- better through typeclasses?

2009-04-25 Thread Thomas Hartman
I tried using the jhc javascript compiler back end a year or so ago. It was too rough to use in production, but it did output javascript from haskell. thomas. 2009/4/25 Miguel Mitrofanov miguelim...@yandex.ru: On 25 Apr 2009, at 21:53, Jason Dusek wrote:  Many Haskell/JS bridges provide

Re: [Haskell-cafe] Haskell/JS -- better through typeclasses?

2009-04-25 Thread Thomas Hartman
On second thought, it was yhc, not jhc: http://lambda-the-ultimate.org/node/1836 2009/4/25 Thomas Hartman tphya...@gmail.com: I tried using the jhc javascript compiler back end a year or so ago. It was too rough to use in production, but it did output javascript from haskell. thomas.

Re: [Haskell-cafe] Haskell/JS -- better through typeclasses?

2009-04-25 Thread Brandon S. Allbery KF8NH
On Apr 25, 2009, at 13:53 , Jason Dusek wrote: I'd like to be able to translate Haskell to JavaScript. http://haskell.org/haskellwiki/Yhc/Javascript ? Many Haskell/JS bridges provide libraries for writing complete JavaScript programs in Haskell; some of them even include jQuery. However,

Re: [Haskell-cafe] Haskell/JS -- better through typeclasses?

2009-04-25 Thread Jason Dusek
2009/04/25 Brandon S. Allbery KF8NH allb...@ece.cmu.edu: 2009/04/25 Jason Dusek:  I'd like to be able to translate Haskell to JavaScript. http://haskell.org/haskellwiki/Yhc/Javascript ? Dead.  Many Haskell/JS bridges provide libraries for writing complete JavaScript programs in Haskell;

Re: [Haskell-cafe] Haskell/JS -- better through typeclasses?

2009-04-25 Thread Jason Dusek
2009/04/25 Miguel Mitrofanov miguelim...@yandex.ru: 2009/04/25 Jason Dusek wrote: Many Haskell/JS bridges provide libraries for writing complete JavaScript programs in Haskell; some of them even include jQuery. However, my goals are more limited -- I'd like to be able to take a Haskell module

Re: [Haskell-cafe] Haskell/JS -- better through typeclasses?

2009-04-25 Thread Jason Dusek
2009/04/25 Thomas Hartman tphya...@gmail.com: 2009/04/25 Thomas Hartman tphya...@gmail.com: I tried using the jhc javascript compiler back end a year or so ago. On second thought, it was yhc, not jhc: http://lambda-the-ultimate.org/node/1836 Yeah, I think that thing has been dead for

Re: [Haskell-cafe] Haskell/JS -- better through typeclasses?

2009-04-25 Thread John A. De Goes
I'd like this functionality, as well, but it doesn't exist, at least for Haskell. If you don't need a 100% pure functional language, and don't need the bells and whistles of the Haskell type system, you might be interested in SML -- a purer relative of the more widely-known Ocaml.

Re: [Haskell-cafe] Haskell/JS -- better through typeclasses?

2009-04-25 Thread Anton Tayanovskyy
For parsers, there is also a LALR(1) generator - http://jscc.jmksf.com/ - though I have not had personal experience with it. --A ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Haskell/JS -- better through typeclasses?

2009-04-25 Thread Jason Dusek
Interesting, thank you. -- Jason Dusek ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] Re: I hate Haskell's typeclasses

2008-04-25 Thread Ben Franksen
Jonathan Cast wrote: Type case is easy: genericShow :: Typeable a = a - String genericShow x = fromJust $ do s - cast x :: Maybe String return s `mplus` do n -

Re: [Haskell-cafe] I hate Haskell's typeclasses

2008-04-22 Thread Ryan Ingram
On Mon, Apr 21, 2008 at 10:58 PM, Jonathan Cast [EMAIL PROTECTED] wrote: I must have failed to communicate well. To me, the point of giving a class a name is that then you can write a program that is parametric over the elements of that class. Knowing that I can implement monads in Ruby

Re: [Haskell-cafe] I hate Haskell's typeclasses

2008-04-22 Thread Derek Elkins
On Mon, 2008-04-21 at 22:58 -0700, Jonathan Cast wrote: class Forceable alpha where seq :: alpha - beta - beta Instances derived automatically by the compiler, when possible, for every type (like Typeable should be). We can omit functions if desired (I don't remember why I thought

Re: [Haskell-cafe] I hate Haskell's typeclasses

2008-04-22 Thread Jonathan Cast
On 22 Apr 2008, at 8:03 PM, Derek Elkins wrote: On Mon, 2008-04-21 at 22:58 -0700, Jonathan Cast wrote: class Forceable alpha where seq :: alpha - beta - beta Instances derived automatically by the compiler, when possible, for every type (like Typeable should be). We can omit functions if

Re: [Haskell-cafe] I hate Haskell's typeclasses

2008-04-22 Thread Jonathan Cast
On 22 Apr 2008, at 9:53 AM, Ryan Ingram wrote: On Mon, Apr 21, 2008 at 10:58 PM, Jonathan Cast [EMAIL PROTECTED] wrote: I must have failed to communicate well. To me, the point of giving a class a name is that then you can write a program that is parametric over the elements of that class.

Re: [Haskell-cafe] I hate Haskell's typeclasses

2008-04-21 Thread Ryan Ingram
the authors have conveniently already made instances of useful typeclasses. Then I try to add some new functionality and run into a lot of friction because now every library I use needs an implementation which matches. Have you ever tried to write a monad transformer that is compatible with the MTL

Re: [Haskell-cafe] I hate Haskell's typeclasses

2008-04-21 Thread Brandon S. Allbery KF8NH
On Apr 21, 2008, at 3:50 , Ryan Ingram wrote: is almost unnecessary; (btw., functions /are/ instances of Show). Now it's my turn to call: Prelude Test.QuickCheck show ((\x - x) :: Int - Int) interactive:1:0: No instance for (Show (Int - Int)) import Data.Function. (but it is indeed a

Re: [Haskell-cafe] I hate Haskell's typeclasses

2008-04-21 Thread Brandon S. Allbery KF8NH
On Apr 21, 2008, at 14:21 , Brandon S. Allbery KF8NH wrote: http://www.cmu.edu.edu/~allbery/FuncShow.hs; note that it only works for monomorphic functions (more Note to self: be more careful when you just woke up. http:// www.ece.cmu.edu/~allbery/FuncShow.hs -- brandon s. allbery

Re: [Haskell-cafe] I hate Haskell's typeclasses

2008-04-21 Thread Jonathan Cast
to embed system F in Haskell via GADTs, but I use a lot of them; and many of them the authors have conveniently already made instances of useful typeclasses. Then I try to add some new functionality and run into a lot of friction because now every library I use needs an implementation which matches

Re: [Haskell-cafe] I hate Haskell's typeclasses

2008-04-20 Thread David MacIver
On Sun, Apr 20, 2008 at 4:46 AM, Jonathan Cast [EMAIL PROTECTED] wrote: On 19 Apr 2008, at 5:02 AM, David MacIver wrote: Independently of the rant... On Sat, Apr 19, 2008 at 6:01 AM, Jonathan Cast [EMAIL PROTECTED] wrote: But why do I need to jump through these hoops for a

Re: [Haskell-cafe] I hate Haskell's typeclasses

2008-04-20 Thread Jonathan Cast
On 20 Apr 2008, at 3:05 AM, David MacIver wrote: On Sun, Apr 20, 2008 at 4:46 AM, Jonathan Cast [EMAIL PROTECTED] wrote: On 19 Apr 2008, at 5:02 AM, David MacIver wrote: Independently of the rant... On Sat, Apr 19, 2008 at 6:01 AM, Jonathan Cast [EMAIL PROTECTED] wrote: But why do I need

Re: [Haskell-cafe] I hate Haskell's typeclasses

2008-04-20 Thread Andrew Coppin
David MacIver wrote: Sure. I'm just saying, it's more of a Jump through this hoop and you shall have moist, delicious cake. And by the way, here's a leg up set up. There are rewards for the hoop jumping, and assistance on the way there (which is more than can be said for a lot of languages which

Re: [Haskell-cafe] I hate Haskell's typeclasses

2008-04-19 Thread David MacIver
Independently of the rant... On Sat, Apr 19, 2008 at 6:01 AM, Jonathan Cast [EMAIL PROTECTED] wrote: But why do I need to jump through these hoops for a perfectly safe commonly desired operation? It's called a proof obligation. Haskell is not here to stop you from jumping through

Re: [Haskell-cafe] I hate Haskell's typeclasses

2008-04-19 Thread Anton van Straaten
David MacIver wrote: Independently of the rant... On Sat, Apr 19, 2008 at 6:01 AM, Jonathan Cast [EMAIL PROTECTED] wrote: But why do I need to jump through these hoops for a perfectly safe commonly desired operation? It's called a proof obligation. Haskell is not here to stop you from

Re: [Haskell-cafe] I hate Haskell's typeclasses

2008-04-19 Thread Jonathan Cast
On 19 Apr 2008, at 5:02 AM, David MacIver wrote: Independently of the rant... On Sat, Apr 19, 2008 at 6:01 AM, Jonathan Cast [EMAIL PROTECTED] wrote: But why do I need to jump through these hoops for a perfectly safe commonly desired operation? It's called a proof obligation. Haskell is

[Haskell-cafe] I hate Haskell's typeclasses

2008-04-18 Thread Ryan Ingram
WARNING: RANT AHEAD. Hopefully this fires off some productive discussion on how to fix these problems! Don't get me wrong: I think the idea of typeclasses is great. Their implementation in Haskell comes so close to being awesome and then falls short, and that's almost worse than not being

Re: [Haskell-cafe] I hate Haskell's typeclasses

2008-04-18 Thread Jonathan Cast
want to work is precisely what this allows. Don't get me wrong: I think the idea of typeclasses is great. Their implementation in Haskell comes so close to being awesome and then falls short, and that's almost worse than not being awesome in the first place! We've noticed. The literature

Re: [Haskell-cafe] Re: Typeclasses and implicit parameters

2007-09-07 Thread ajb
G'day all. Quoting Chung-chieh Shan [EMAIL PROTECTED]: Yes. You can even do this portably, using nothing unsafe, with Dylan Thurston's technique: That paper gives you a choice between inefficient and leaky. I think I'll take unsafeCoerce#. :-) Cheers, Andrew Bromage

RE: [Haskell-cafe] Typeclasses and implicit parameters

2007-09-06 Thread Simon Peyton-Jones
| -- Hugs allows this. GHC rejects it on the grounds that a is unused | -- on the right-hand side of the (=). I think this is arguably a bug | -- in GHC. | f3 :: (Show a, ?foo :: a) = String | f3 = show ?foo Hugs is right here. GHC 6.8 accepts this too, and has done for some time; there's

RE: [Haskell-cafe] Typeclasses and implicit parameters

2007-09-06 Thread ajb
G'day all. Quoting Simon Peyton-Jones [EMAIL PROTECTED]: | -- GHC rejects this. Hugs compiles it, but I can't call it as | -- let ?foo = Hello in show Foo | -- | -- Is there a good reason to disallow this? | data Foo = Foo | | instance (?foo :: String) = Show Foo where | showsPrec _ Foo =

Re: [Haskell-cafe] Typeclasses and implicit parameters

2007-09-06 Thread Stefan O'Rear
On Thu, Sep 06, 2007 at 06:49:21AM -0400, [EMAIL PROTECTED] wrote: For completeness, here's the final solution, courtesy of int-e (whose real name I don't know; sorry), which is much more elegant than I Bertram Felgenhauer bindString :: (forall s. StringAsType s = Mark s a) - String - a

[Haskell-cafe] Re: Typeclasses and implicit parameters

2007-09-06 Thread Chung-chieh Shan
[EMAIL PROTECTED] wrote in article [EMAIL PROTECTED] in gmane.comp.lang.haskell.cafe: That higher-rank type makes all the difference. Yes. You can even do this portably, using nothing unsafe, with Dylan Thurston's technique: Oleg Kiselyov and Chung-chieh Shan. 2004. Functional pearl: Implicit

[Haskell-cafe] Typeclasses and implicit parameters

2007-08-09 Thread ajb
{-# OPTIONS -fglasgow-exts #-} -- G'day everyone. -- This is okay. f1 :: (?foo :: String) = String f1 = ?foo -- So is this. f2 :: (Show a, ?foo :: a) = a - String f2 _ = show ?foo -- Hugs allows this. GHC rejects it on the grounds that a is unused -- on the right-hand side of the (=). I

[Haskell-cafe] Re: GADT and typeclasses [was: Language extensions]

2007-05-28 Thread apfelmus
like data Color = Red | Green | Blue can be implemented with typeclasses and without |. Thus, we don't need them... :) The other point is that using existentials for sums has a problem: I think it's impossible to implement many functions that take multiple arguments of the existential type

[Haskell-cafe] GADT and typeclasses [was: Language extensions]

2007-05-27 Thread oleg
term algebra Initial (term) algebra for a state monad http://www.haskell.org/pipermail/haskell-cafe/2005-January/008241.html Implementing an interpreter in HOAS with fix Even higher-order abstract syntax: typeclasses vs GADT http://www.haskell.org/pipermail

Re: [Haskell-cafe] GADT and typeclasses [was: Language extensions]

2007-05-27 Thread Philippa Cowderoy
monad in a free term algebra Initial (term) algebra for a state monad http://www.haskell.org/pipermail/haskell-cafe/2005-January/008241.html Implementing an interpreter in HOAS with fix Even higher-order abstract syntax: typeclasses vs GADT http://www.haskell.org

RE: [Haskell-cafe] GADTs and Typeclasses

2007-04-16 Thread Simon Peyton-Jones
| Will I run into problems using typeclasses with GADTs? No, you shouldn't, provided you use the HEAD compiler. I did a fairly major upgrade, after the 6.6 fork, which makes the interaction between type classes and GADTs work properly. This upgrade isn't in 6.6, and I regard the type-class

[Haskell-cafe] GADTs and Typeclasses

2007-04-15 Thread Dominic Steinitz
Will I run into problems using typeclasses with GADTs? I've come up with this to model a fragment of ASN.1. I'd hate to spend a lot of time on this only to find out it's well known that these two features don't mix very well. Thanks, Dominic. data Type :: * - * where INTEGER

[Haskell-cafe] GADTs vs arrows/typeclasses

2006-12-06 Thread S. Alexander Jacobson
I don't think I'm the only one confused here. Henrik Nilson in his paper on adding GADTs to Yampa comments that: However, the recent addition of Generalized Algebraic Data Types (GADTs) [26] to the list of Haskell extensions supported by the Glasgow Haskell Compiler (GHC) gives

Re: [Haskell-cafe] GADTs vs arrows/typeclasses

2006-12-06 Thread Daniel McAllansmith
On Thursday 07 December 2006 09:44, S. Alexander Jacobson wrote: I guess I'm also not sure what belongs in a GADT and what belongs in a typeclass e.g. here is an Arrow GADT data Arrow b c where Arr::(b-c) - Arrow b c Compose::Arrow b c - Arrow c d - Arrow b d First::Arrow

[Haskell-cafe] Re: GADTs vs arrows/typeclasses

2006-12-06 Thread Arie Peterson
Hi Alex, S. Alexander Jacobson wrote: I guess I'm also not sure what belongs in a GADT and what belongs in a typeclass e.g. here is an Arrow GADT data Arrow b c where Arr::(b-c) - Arrow b c Compose::Arrow b c - Arrow c d - Arrow b d First::Arrow a b - Arrow (a,c) (b,c)

  1   2   >