Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

HASKELL

Name: Anonymous 2007-10-30 19:37

So I wrote this sweet code to determine the arity of a function in Haskell:
class Arity a where
    arity :: a -> Integer
instance (Arity b) => Arity (a -> b) where
    arity f = 1 + arity $ f undefined
instance Arity (a -> b) where
    arity _ = 1

But it won't work. GHC complains about overlapping instances, and I kind of understand where its coming from; there is some ambiguity there. Does anyone know how to make this work?

I've also run into other problems with overlapping instances. For example, I know the Show class has to use a hack to get around the ambiguity between (Show a) => [a] and [Char]. Why can't the compiler just choose the most specific instance?

Name: Anonymous 2007-10-30 19:59

ITS BECAUSE YOU SUCK LOLOLOLOL!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Name: Anonymous 2007-10-30 20:00

Haskell is crap. Case closed.

Name: Anonymous 2007-10-30 20:01

I don't know.

Name: Anonymous 2007-10-30 20:10

>>3
yo
yo
yo

Please don't turn this into a language war. Choose the right tool for the right job, I always say! Haskell certainly has its uses, and I find it fun to program in :).

nigger

Name: Anonymous 2009-03-06 8:30

problems that made me   hate Sepples even.

Name: Anonymous 2010-12-09 1:44

Name: Anonymous 2011-02-02 23:43

Name: Anonymous 2011-02-03 8:07

Name: Anonymous 2011-08-02 12:58

sagesage

Don't change these.
Name: Email:
Entire Thread Thread List