Send Beginners mailing list submissions to
        beginners@haskell.org

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
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

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


Today's Topics:

   1. Re:  Generalised data constructor matching (Chadda? Fouch?)
   2. Re:  Generalised data constructor matching (Daniel Fischer)
   3.  Re: Haskell data structures: cheap immutable manipulation
      and nested equality? (Heinrich Apfelmus)
   4.  graphics.ui.wxcore (John Moore)
   5. Re:  graphics.ui.wxcore (Daniel Fischer)
   6.  Urgent: Defining Momory data Types in Haskell (Akshay Dave)
   7. Re:  Urgent: Defining Momory data Types in Haskell
      (Peter Verswyvelen)
   8. RE:  Urgent: Defining Momory data Types in Haskell (Akshay Dave)


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

Message: 1
Date: Sat, 5 Sep 2009 09:53:34 +0200
From: Chadda? Fouch? <chaddai.fou...@gmail.com>
Subject: Re: [Haskell-beginners] Generalised data constructor matching
To: Daniel Fischer <daniel.is.fisc...@web.de>
Cc: beginners@haskell.org
Message-ID:
        <e9350eaf0909050053y72016542w2748488566794...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

On Fri, Sep 4, 2009 at 2:57 PM, Daniel Fischer<daniel.is.fisc...@web.de> wrote:
> In general: not.
> The problem is that potentially every datatype can be made an instance of the 
> class, so in
> the default implementations, you can only[*] use functions which work on 
> every datatype.
> There aren't many interesting functions that do.
>
> [*]well, you can also use methods of the class and superclasses.

And so by using Data and Typeable as superclasses, he could do what he
is asking for... And Data and Typeable are automatically derivables by
GHC (extension).

-- 
Jedaï


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

Message: 2
Date: Sat, 5 Sep 2009 14:45:25 +0200
From: Daniel Fischer <daniel.is.fisc...@web.de>
Subject: Re: [Haskell-beginners] Generalised data constructor matching
To: Chadda? Fouch? <chaddai.fou...@gmail.com>
Cc: beginners@haskell.org
Message-ID: <200909051445.25550.daniel.is.fisc...@web.de>
Content-Type: text/plain;  charset="utf-8"

Am Samstag 05 September 2009 09:53:34 schrieb Chaddaï Fouché:
> On Fri, Sep 4, 2009 at 2:57 PM, Daniel Fischer<daniel.is.fisc...@web.de> 
> wrote:
> > In general: not.
> > The problem is that potentially every datatype can be made an instance of
> > the class, so in the default implementations, you can only[*] use
> > functions which work on every datatype. There aren't many interesting
> > functions that do.
> >
> > [*]well, you can also use methods of the class and superclasses.
>
> And so by using Data and Typeable as superclasses, he could do what he
> is asking for... And Data and Typeable are automatically derivables by
> GHC (extension).

True. But I don't think the code would become any shorter/better/easier to 
maintain 
(*shudder*), so I'd stick to individual instance declarations.


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

Message: 3
Date: Sun, 06 Sep 2009 17:07:19 +0200
From: Heinrich Apfelmus <apfel...@quantentunnel.de>
Subject: [Haskell-beginners] Re: Haskell data structures: cheap
        immutable manipulation and nested equality?
To: beginners@haskell.org
Message-ID: <h80j7a$k9...@ger.gmane.org>
Content-Type: text/plain; charset=ISO-8859-1

Anand Patil wrote:
Heinrich Apfelmus wrote:
>> Anand Patil wrote:
>>> - Cheap equality by value:
>>> 
>>> user=> (= m {:a 1 :b 2 :c {:d 3 :f 4}})
>>> false
>>> user=> (= m {:a 1 :b 2})
>>> true
>>> 
>>> If I understand correctly, equality is computed based on some kind of
>>> hash rather than by comparing the two maps element by element, so it's
>>> efficient even for large and/or nested collections.
>> 
>> Why would you need this feature? I can only think of common
>> subexpression elimination.
>
> I have an expensive function that takes complicated data structures as
> an argument, and I know that it will often be evaluated twice running
> with the same argument, but it will be evaluated with lots of
> different arguments over the course of the program. A cheap equality
> test would make it easy to cache the last return value. Is there a
> better way to optimize this in Haskell?

Sounds indeed like a case for memoization to me. (While complicated data
structures as keys sounds suspicious, in my opinion.)

Cheap equality won't necessarily help, though, you want at least the
hash value itself. But since calculating a hash will take O(length of
complicated data structure) anyway, you can also use a memoization
scheme based on "sums of products" which has the same complexity^1. In
particular, have a look at

   http://hackage.haskell.org/package/data-memocombinators

which is used like this:

   fib = Memo.integral fib'
      where
      fib' 0 = 0
      fib' 1 = 1
      fib' x = fib (x-1) + fib (x-2)

You'll have to combine existing memo combinators to make one for your
data structure; feel free to ask if you need more info on that.


^1: For common subexpression elimination, intermediate hashes count as
well, so this comparison doesn't apply.


Regards,
apfelmus

--
http://apfelmus.nfshost.com



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

Message: 4
Date: Sun, 6 Sep 2009 19:37:40 +0100
From: John Moore <john.moor...@gmail.com>
Subject: [Haskell-beginners] graphics.ui.wxcore
To: beginners@haskell.org
Message-ID:
        <4f7ad1ad0909061137i30ab793bo55830c0478b90...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hi,
     Could someone please explain how to intall this. I have installed ghc
and gtk2Hs and tried running small programs to get an idea of the gui system
in Haskell. It keeps telling me cannot find graphics.ui.wxcore. Module
failed etc. I just very recently started to learn Haskell. ( I need an idea
for my final year project which at this moment is on functional programming
and want to find advantages/disadvantages of the gui system in Haskell)
                                   Regards
                                   John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20090906/af752a11/attachment-0001.html

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

Message: 5
Date: Sun, 6 Sep 2009 20:53:35 +0200
From: Daniel Fischer <daniel.is.fisc...@web.de>
Subject: Re: [Haskell-beginners] graphics.ui.wxcore
To: beginners@haskell.org
Message-ID: <200909062053.35262.daniel.is.fisc...@web.de>
Content-Type: text/plain;  charset="iso-8859-15"

Am Sonntag 06 September 2009 20:37:40 schrieb John Moore:
> Hi,
>      Could someone please explain how to intall this. I have installed ghc
> and gtk2Hs and tried running small programs to get an idea of the gui
> system in Haskell. It keeps telling me cannot find graphics.ui.wxcore.

That would be in the wxcore package, as far as I know it has nothing to do with 
gtk2hs.
Try
cabal update && cabal install wx

(wx is the higher level GUI package on top of wxcore)

> Module failed etc. I just very recently started to learn Haskell. ( I need
> an idea for my final year project which at this moment is on functional
> programming and want to find advantages/disadvantages of the gui system in
> Haskell) Regards
>                                    John



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

Message: 6
Date: Mon, 7 Sep 2009 05:28:58 +0000
From: Akshay Dave <akshay.v.d...@hotmail.com>
Subject: [Haskell-beginners] Urgent: Defining Momory data Types in
        Haskell
To: <beginners@haskell.org>
Message-ID: <blu130-w2451afde988d8f2dd9c02ba6...@phx.gbl>
Content-Type: text/plain; charset="iso-8859-1"








Hi All,
   I am stuck in converting the transition semantics in
Haskell. Please let me know how to define memory data types in Haskell(
like we define pointer in C). Prompt help would be greatly appreciated.

Sincerely,
Akshay
_________________________________________________________________
With Windows Live, you can organize, edit, and share your photos.
http://www.windowslive.com/Desktop/PhotoGallery
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20090907/ac3a8d50/attachment-0001.html

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

Message: 7
Date: Mon, 7 Sep 2009 08:28:51 +0200
From: Peter Verswyvelen <bugf...@gmail.com>
Subject: Re: [Haskell-beginners] Urgent: Defining Momory data Types in
        Haskell
To: Akshay Dave <akshay.v.d...@hotmail.com>
Cc: beginners@haskell.org
Message-ID:
        <a88790d10909062328h12f7e111i13d7e45d542fb...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

I don't think you provided enough information to give a full answer,
at least not to me.

Briefly, if you want to use pointers as in C, then use IORef or STRef
and the IO resp ST monad.

If you refer to the ability to define recursive structures in C using
pointers like

struct IntNode
{
     int value;
     IntNode* next;
}

then you can just use Haskell's algebraic data types (ADTs), like

data IntNode = IntNodeTag Int IntNode

Of course this particular example is just a list of integers in
Haskell, and on lists you have a multitude of premade functions to
manipulate them.

But I guess this is not the answer you've been looking for? More about
this can be found in any standard Haskell text book or the wikis


On Mon, Sep 7, 2009 at 7:28 AM, Akshay Dave<akshay.v.d...@hotmail.com> wrote:
> Hi All,
>    I am stuck in converting the transition semantics in Haskell. Please let
> me know how to define memory data types in Haskell( like we define pointer
> in C). Prompt help would be greatly appreciated.
>
> Sincerely,
> Akshay
> ________________________________
> With Windows Live, you can organize, edit, and share your photos. Click
> here.
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>


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

Message: 8
Date: Mon, 7 Sep 2009 06:37:16 +0000
From: Akshay Dave <akshay.v.d...@hotmail.com>
Subject: RE: [Haskell-beginners] Urgent: Defining Momory data Types in
        Haskell
To: <bugf...@gmail.com>
Cc: Beginners Haskell <beginners@haskell.org>
Message-ID: <blu130-w16b66d22af280cd092e151a6...@phx.gbl>
Content-Type: text/plain; charset="iso-8859-1"


Hi,
   Thanks for your prompt reply. Actually I am trying to convert the following 
transitive semantics to Haskell:

(Memory maps I to Z)
lookup m i = <current value of i>  ( meaning lookup for I in memory m)

evB b m = true/(while b do c od;m) -> (c; while b do c od;m)

I have written the boolean expression and statement part but I am not able to 
write the memory representation in Haskell.

Hope above explanation helps.

Cheers!
Akshay

> Date: Mon, 7 Sep 2009 08:28:51 +0200
> Subject: Re: [Haskell-beginners] Urgent: Defining Momory data Types in Haskell
> From: bugf...@gmail.com
> To: akshay.v.d...@hotmail.com
> CC: beginners@haskell.org
> 
> I don't think you provided enough information to give a full answer,
> at least not to me.
> 
> Briefly, if you want to use pointers as in C, then use IORef or STRef
> and the IO resp ST monad.
> 
> If you refer to the ability to define recursive structures in C using
> pointers like
> 
> struct IntNode
> {
>      int value;
>      IntNode* next;
> }
> 
> then you can just use Haskell's algebraic data types (ADTs), like
> 
> data IntNode = IntNodeTag Int IntNode
> 
> Of course this particular example is just a list of integers in
> Haskell, and on lists you have a multitude of premade functions to
> manipulate them.
> 
> But I guess this is not the answer you've been looking for? More about
> this can be found in any standard Haskell text book or the wikis
> 
> 
> On Mon, Sep 7, 2009 at 7:28 AM, Akshay Dave<akshay.v.d...@hotmail.com> wrote:
> > Hi All,
> >    I am stuck in converting the transition semantics in Haskell. Please let
> > me know how to define memory data types in Haskell( like we define pointer
> > in C). Prompt help would be greatly appreciated.
> >
> > Sincerely,
> > Akshay
> > ________________________________
> > With Windows Live, you can organize, edit, and share your photos. Click
> > here.
> > _______________________________________________
> > Beginners mailing list
> > Beginners@haskell.org
> > http://www.haskell.org/mailman/listinfo/beginners
> >
> >

_________________________________________________________________
Get back to school stuff for them and cashback for you.
http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20090907/841a1931/attachment.html

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

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 15, Issue 4
****************************************

Reply via email to