Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  Relatively simple undirected graph library? (Stefan H?ck)
   2. Re:  typeclass woes...how to constain a typeclass to be
      "closed" under an operation.... (akash g)


----------------------------------------------------------------------

Message: 1
Date: Tue, 6 Jan 2015 19:03:46 +0100
From: Stefan H?ck <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Relatively simple undirected graph
        library?
Message-ID: <[email protected]>
Content-Type: text/plain; charset=iso-8859-1

OK, I'll try and clean up the code and put it on GitHub. Mind that it's
no big thing so far, but will hopefully evolve to something useful ...

On Tue, Jan 06, 2015 at 09:55:16AM +0100, Tim Holzschuh wrote:
> Hi Stefan!
> 
> Although I don't need such a library for the moment, and although I'm still
> a beginner and I probably won't be able to improve your library I'd still
> love to see it on GitHub - just to check your code.
> 
> So if you don't mind to have it online "for free" it would be really nice,
> if you'd put it on your GitHub!
> 
> Thanks,
>     Tim
> 
> Am 05.01.2015 um 05:26 schrieb Stefan H?ck:
> >Hi Stu I also was in need of a graph library comparable to what you
> >describe, which I'd like to use later on to represent molecular graphs in
> >cheminformatics projects. Since I did not find anything that fit my needs
> >on Hackage, I started writing my own implementation. The code is not ready
> >for anything and so far it's only unlabeled graphs. However, adding
> >labelings later on is - from my experience - no big thing as most of the
> >graph algorithms need only be implemented for unlabeled graphs. If you are
> >interested, I could clean up the code and put it on github, then we could
> >work on it together. Many of the things you need like creating edge- and
> >vertex-induced subgraphs will require only very little work. The same goes
> >for extracting connected subgraphs and filtering by edge or vertex type.
> >Stefan _______________________________________________ Beginners mailing
> >list [email protected]
> >http://www.haskell.org/mailman/listinfo/beginners
> 


------------------------------

Message: 2
Date: Wed, 7 Jan 2015 14:24:28 +0530
From: akash g <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] typeclass woes...how to constain a
        typeclass to be "closed" under an operation....
Message-ID:
        <CALiga_fWPxvsnYHdjooUjE=zrxsrblyhffz_0by2nkh1zma...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

(S Integer) is not an instance of Bar.  I solved this by doing the following

You can get around this using an empty instance declaration for (S Integer)
like so

instance Bar (S Integer)

Now, the compiler will know that (S Integer) is an instance of this.  It
doesn't matter if there is no definition of inc' as you won't be using it.

However, I don't understand why a class definition will contain itself as a
constraint on one of its method.  By doing so,

That is, whenever you do something like this

class Bar a where
  inc' ::  Bar (S a) => a -> S a

instance Bar Integer where
  inc' x = S x

The resulting expression will also have to be an instance of Bar
(.ie.,instance Bar (S Integer)
)  I just don't think this makes any sense.  Also, tried searching for any
such type signatures in Hoogle, but didn't come across anything like this.



On Tue, Jan 6, 2015 at 11:09 PM, Nicholls, Mark <[email protected]>
wrote:

>  I can do the basic Haskell?I?ve done a course even, but as I don?t use
> it? I quickly degenerate into a beginner.
>
>
>
> I think I?ve refound my feet?.I will post it to the caf? and see what
> happens.
>
>
>
> *From:* Beginners [mailto:[email protected]] *On Behalf Of *David
> McBride
> *Sent:* 06 January 2015 4:41 PM
> *To:* The Haskell-Beginners Mailing List - Discussion of primarily
> beginner-level topics related to Haskell
> *Subject:* Re: [Haskell-beginners] typeclass woes...how to constain a
> typeclass to be "closed" under an operation....
>
>
>
> I think you've slightly surpassed the skill level of this list.  You might
> try on haskell-cafe, and I would bet you could get an in depth answer on
> stackoverflow.
>
>
>
> On Tue, Jan 6, 2015 at 3:46 AM, Nicholls, Mark <[email protected]>
> wrote:
>
> I dont seem to have any replies
>
> Booo
>
> Is my question too stupid? Or boring? Or unintelligable?
>
>
>
> Its quite common in maths to have operations in a theory that are (set)
> closed, i just want to translate that notion to a typeclass
>
>
>
> I have a suggestion that does work
>
>
>
> Class Foo m where
>
>    op :: m a -> m (S a)
>
>
>
> That is closed, but now were working on types of kind ? -> ?, which is
> another leap of complexity
>
>
>
> Is this the idiom/pattern i should follow? Or can the closure contraint be
> expressed directly?
>
>
>
>
>
> Excuse the spelling, sent from a phone with itty bitty keys, it like
> trying to sow a button on a shirt with a sausage.
>
>
>
>
> On 5 Jan 2015, at 10:54, Nicholls, Mark <[email protected]> wrote:
>
>   > {-# LANGUAGE TypeFamilies, MultiParamTypeClasses, FlexibleContexts,
> FlexibleInstances, GADTs #-}
>
>
>
> lets say I have a data type
>
>
>
> > data S a = S a deriving Show
>
>
>
> and a nice simple typeclass
>
>
>
> > class Foo a where
>
> >   inc :: a -> S a
>
>
>
> make Integer an instance and....
>
>
>
> > instance Foo Integer where
>
> >   inc x = S x
>
>
>
> brilliant...
>
>
>
> now lets say I want my typeclass to enforce that any result of inc is also
> of a type that is an instance of the typeclass
>
> I'll follow my nose...which causes me a problem that makes me realise I
> maybe I don't understand whats going on.
>
>
>
> > class Bar a where
>
> >   inc' :: (Bar (S a)) => a -> S a
>
>
>
> follow it to....
>
>
>
> > instance Bar Integer where
>
> >   inc' x = S x
>
>
>
> this WORKS!...even though "S Integer" is not an instance of Bar!...maybe I
> don't understand.
>
>
>
> > -- x = inc' (1 :: Integer)
>
>
>
> This would go BOOM ....?no instance of (Bar (S Integer))"
>
> ...so that makes sense....
>
>
>
> How do I force Haskell to check the constraint before I evaluate an
> expression?
>
>
>
> follow my nose?
>
>
>
> > -- class (Baz (S a)) => Baz a where
>
> > --  inc'' :: a -> S a
>
>
>
> BOOM ...."Cycle in class declaration"....
>
> booo..but I suppose thats understandable....
>
>
>
> so
>
>
>
> a) is my use of typeclasses correct?...or am I missing something?
>
> b) if so, how do I force the compiler to make sure my typeclass operations
> is nicely closed (under the typeclass)?
>
>
>
>
>
>
>
> CONFIDENTIALITY NOTICE
>
> This e-mail (and any attached files) is confidential and protected by
> copyright (and other intellectual property rights). If you are not the
> intended recipient please e-mail the sender and then delete the email and
> any attached files immediately. Any further use or dissemination is
> prohibited.
>
> While MTV Networks Europe has taken steps to ensure that this email and
> any attachments are virus free, it is your responsibility to ensure that
> this message and any attachments are virus free and do not affect your
> systems / data.
>
> Communicating by email is not 100% secure and carries risks such as delay,
> data corruption, non-delivery, wrongful interception and unauthorised
> amendment. If you communicate with us by e-mail, you acknowledge and assume
> these risks, and you agree to take appropriate measures to minimise these
> risks when e-mailing us.
>
> MTV Networks International, MTV Networks UK & Ireland, Greenhouse,
> Nickelodeon Viacom Consumer Products, VBSi, Viacom Brand Solutions
> International, Be Viacom, Viacom International Media Networks and VIMN and
> Comedy Central are all trading names of MTV Networks Europe.  MTV Networks
> Europe is a partnership between MTV Networks Europe Inc. and Viacom
> Networks Europe Inc.  Address for service in Great Britain is 17-29 Hawley
> Crescent, London, NW1 8TT.
>
>   _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
>
> CONFIDENTIALITY NOTICE
>
> This e-mail (and any attached files) is confidential and protected by
> copyright (and other intellectual property rights). If you are not the
> intended recipient please e-mail the sender and then delete the email and
> any attached files immediately. Any further use or dissemination is
> prohibited.
>
> While MTV Networks Europe has taken steps to ensure that this email and
> any attachments are virus free, it is your responsibility to ensure that
> this message and any attachments are virus free and do not affect your
> systems / data.
>
> Communicating by email is not 100% secure and carries risks such as delay,
> data corruption, non-delivery, wrongful interception and unauthorised
> amendment. If you communicate with us by e-mail, you acknowledge and assume
> these risks, and you agree to take appropriate measures to minimise these
> risks when e-mailing us.
>
> MTV Networks International, MTV Networks UK & Ireland, Greenhouse,
> Nickelodeon Viacom Consumer Products, VBSi, Viacom Brand Solutions
> International, Be Viacom, Viacom International Media Networks and VIMN and
> Comedy Central are all trading names of MTV Networks Europe.  MTV Networks
> Europe is a partnership between MTV Networks Europe Inc. and Viacom
> Networks Europe Inc.  Address for service in Great Britain is 17-29 Hawley
> Crescent, London, NW1 8TT.
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
>
>
>
> CONFIDENTIALITY NOTICE
>
> This e-mail (and any attached files) is confidential and protected by
> copyright (and other intellectual property rights). If you are not the
> intended recipient please e-mail the sender and then delete the email and
> any attached files immediately. Any further use or dissemination is
> prohibited.
>
> While MTV Networks Europe has taken steps to ensure that this email and
> any attachments are virus free, it is your responsibility to ensure that
> this message and any attachments are virus free and do not affect your
> systems / data.
>
> Communicating by email is not 100% secure and carries risks such as delay,
> data corruption, non-delivery, wrongful interception and unauthorised
> amendment. If you communicate with us by e-mail, you acknowledge and assume
> these risks, and you agree to take appropriate measures to minimise these
> risks when e-mailing us.
>
> MTV Networks International, MTV Networks UK & Ireland, Greenhouse,
> Nickelodeon Viacom Consumer Products, VBSi, Viacom Brand Solutions
> International, Be Viacom, Viacom International Media Networks and VIMN and
> Comedy Central are all trading names of MTV Networks Europe.  MTV Networks
> Europe is a partnership between MTV Networks Europe Inc. and Viacom
> Networks Europe Inc.  Address for service in Great Britain is 17-29 Hawley
> Crescent, London, NW1 8TT.
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20150107/074153ba/attachment.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 79, Issue 10
*****************************************

Reply via email to