[Haskell-cafe] Haskell 101 on classes .... duh ..... :^)

Vasili I. Galchin vigalchin at gmail.com
Wed Sep 14 02:00:14 CEST 2011


Hi Brandon,

     Here is Ivan's web site. http://ivanmiljenovic.wordpress.com/  ...... I
have written in Haskell before ... a POSIX Realtime hackage package. It is
true I am little rusty now .... because industry is too stubborn except in
places like Silicon Valley, Wall Street, Virginia (defence industry) to use
FPLs ... have to pay the bills sadly...

Vasili


On Tue, Sep 13, 2011 at 9:57 AM, Brandon Allbery <allbery.b at gmail.com>wrote:

> On Tue, Sep 13, 2011 at 00:08, Vasili I. Galchin <vigalchin at gmail.com>wrote:
>
>>       I am trying to model multigraphs ....but getting errors with ghci
>> and can't figure out why.... I have a serious blind spot ....
>>
>
> Why do you need to use classes for this?  (Note:  forget everything you
> know about classes from OOP.  Haskell typeclasses have approximately nothing
> to do with OOP.)
>
> junk1.hs:19:12:
>>     Constructor `Arrow' should have 1 argument, but has been given 0
>>     In the pattern: Arrow
>>     In the definition of `source': source Arrow = fst Arrow
>>     In the instance declaration for `Graph Arrow Int'
>>
>
> It's asking "Arrow *what*?"  You specified Arrow as taking a tuple
> argument; if you want to use it here, you need to provide that argument (or
> a placeholder, but in this case you clearly want the tuple).
>
> >   source (Arrow p) = fst p
> >   target (Arrow p) = snd p
>
> Or you can use pattern matching to deconstruct the tuple as well:
>
> >   source (Arrow (f,_)) = f
> >   target (Arrow (_,t)) = t
>
> --
> brandon s allbery                                      allbery.b at gmail.com
> wandering unix systems administrator (available)     (412) 475-9364 vm/sms
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110913/05535093/attachment.htm>


More information about the Haskell-Cafe mailing list