Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/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. Comparison between fields of each record (Jeon-Young Kang)
2. Re: Comparison between fields of each record
(Dimitri DeFigueiredo)
3. Re: [Haskell-cafe] Comparison between fields of each record
(Francesco Ariis)
4. Re: [Haskell-cafe] Comparison between fields of each record
(Jeon-Young Kang)
5. Re: [Haskell-cafe] Comparison between fields of each record
(MJ Williams)
6. Simple function comparison (Stephen Renehan)
----------------------------------------------------------------------
Message: 1
Date: Tue, 24 Nov 2015 13:20:03 -0500
From: Jeon-Young Kang <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>,
[email protected]
Subject: [Haskell-beginners] Comparison between fields of each record
Message-ID:
<CALWtiK_Gtsw2j9_EtcvGAHssinpf5rhm=yyr0t2_qjzj0gz...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Dear All.
I'd like to compare fields of each record.
here is my record.
data Person = Person {name:: String, age:: Int } deriving(Show)
data Relations = Friend | Older | Younger
class Comparison a where
compare:: a -> a -> Relations
instance Comparison Person where
compare Person a b Person a b
| b1 == b2 = Friend
| b1 > b2 = Older
| b1 < b2 = Younger
How can I fit it?
Sincerely,
Jeon-Young Kang
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20151124/cd23cd3c/attachment-0001.html>
------------------------------
Message: 2
Date: Tue, 24 Nov 2015 11:57:58 -0700
From: Dimitri DeFigueiredo <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Comparison between fields of each
record
Message-ID: <[email protected]>
Content-Type: text/plain; charset="windows-1252"; Format="flowed"
I don't understand your question but the class Ord in Data.Ord is our
tool for comparisons. You may want to look into that. You can also
use the function "on" from Data.Function to compare on a specific record
within a larger structure.
Dimitri
On 11/24/15 11:20 AM, Jeon-Young Kang wrote:
> Dear All.
>
> I'd like to compare fields of each record.
>
> here is my record.
>
> data Person = Person {name:: String, age:: Int } deriving(Show)
> data Relations = Friend | Older | Younger
>
> class Comparison a where
> compare:: a -> a -> Relations
>
> instance Comparison Person where
> compare Person a b Person a b
> | b1 == b2 = Friend
> | b1 > b2 = Older
> | b1 < b2 = Younger
>
> How can I fit it?
>
> Sincerely,
>
> Jeon-Young Kang
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20151124/4fa80ba9/attachment-0001.html>
------------------------------
Message: 3
Date: Tue, 24 Nov 2015 20:01:08 +0100
From: Francesco Ariis <[email protected]>
To: Jeon-Young Kang <[email protected]>
Cc: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>,
[email protected]
Subject: Re: [Haskell-beginners] [Haskell-cafe] Comparison between
fields of each record
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
On Tue, Nov 24, 2015 at 01:20:03PM -0500, Jeon-Young Kang wrote:
> Dear All.
>
> I'd like to compare fields of each record.
>
> here is my record.
>
> data Person = Person {name:: String, age:: Int } deriving(Show)
> data Relations = Friend | Older | Younger
>
> class Comparison a where
> compare:: a -> a -> Relations
>
> instance Comparison Person where
> compare Person a b Person a b
> | b1 == b2 = Friend
> | b1 > b2 = Older
> | b1 < b2 = Younger
>
> How can I fit it?
>
> Sincerely,
>
>
> Jeon-Young Kang
Hello Jeon-Young, I attach a version that compiles. Keep in mind that
compare (Person x y) (Person q w) -- this is legal
compare Person x y Person q w -- "space" takes precedence over everything,
-- so this function has 6 arguments
-- instead of the expected 2!
?> Main.compare (Person "cdsac" 1) (Person "cdscasd" 20)
Younger
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.hs
Type: text/x-haskell
Size: 343 bytes
Desc: not available
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20151124/05b234a7/attachment-0001.hs>
------------------------------
Message: 4
Date: Tue, 24 Nov 2015 14:14:01 -0500
From: Jeon-Young Kang <[email protected]>
To: Jeon-Young Kang <[email protected]>, The Haskell-Beginners
Mailing List - Discussion of primarily beginner-level topics related
to Haskell <[email protected]>, [email protected]
Subject: Re: [Haskell-beginners] [Haskell-cafe] Comparison between
fields of each record
Message-ID:
<CALWtiK-Z3hwn=abceuc7yz+rn5jlxcfxznwhrdfmqm366m5...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Thank you so much :)
On Tue, Nov 24, 2015 at 2:01 PM, Francesco Ariis <[email protected]> wrote:
> On Tue, Nov 24, 2015 at 01:20:03PM -0500, Jeon-Young Kang wrote:
> > Dear All.
> >
> > I'd like to compare fields of each record.
> >
> > here is my record.
> >
> > data Person = Person {name:: String, age:: Int } deriving(Show)
> > data Relations = Friend | Older | Younger
> >
> > class Comparison a where
> > compare:: a -> a -> Relations
> >
> > instance Comparison Person where
> > compare Person a b Person a b
> > | b1 == b2 = Friend
> > | b1 > b2 = Older
> > | b1 < b2 = Younger
> >
> > How can I fit it?
> >
> > Sincerely,
> >
> >
> > Jeon-Young Kang
>
> Hello Jeon-Young, I attach a version that compiles. Keep in mind that
>
> compare (Person x y) (Person q w) -- this is legal
>
> compare Person x y Person q w -- "space" takes precedence over
> everything,
> -- so this function has 6 arguments
> -- instead of the expected 2!
>
>
> ?> Main.compare (Person "cdsac" 1) (Person "cdscasd" 20)
> Younger
>
--
Department of Geography
State University of New York at Buffalo
[email protected]
Jeon-Young Kang
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20151124/014f44cc/attachment-0001.html>
------------------------------
Message: 5
Date: Wed, 25 Nov 2015 02:42:32 +0000
From: MJ Williams <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] [Haskell-cafe] Comparison between
fields of each record
Message-ID:
<CAAKj9FNSfJjknYvYxcU71h6gDhC0=sgrvapre1xd3etzssp...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
Okay, can I ask you to provide a little more explanation of what you
want to perform with your code? To me, at least, the question, "How
can I fit it?" is a little too terse.
I think before you even set up a new data, class, class instances
etc., the most key step is to put in words, the simpler and cleaer the
better, exactly what you what the code to do for you. Pseudo code in
prose, if you like. You'll find that with clarity of thought expressed
in words comes a greater command of the programming language, or at
least, a clearer idea of what you want from the programming language.
Matthew
On 24/11/2015, Jeon-Young Kang <[email protected]> wrote:
> Thank you so much :)
>
> On Tue, Nov 24, 2015 at 2:01 PM, Francesco Ariis <[email protected]> wrote:
>
>> On Tue, Nov 24, 2015 at 01:20:03PM -0500, Jeon-Young Kang wrote:
>> > Dear All.
>> >
>> > I'd like to compare fields of each record.
>> >
>> > here is my record.
>> >
>> > data Person = Person {name:: String, age:: Int } deriving(Show)
>> > data Relations = Friend | Older | Younger
>> >
>> > class Comparison a where
>> > compare:: a -> a -> Relations
>> >
>> > instance Comparison Person where
>> > compare Person a b Person a b
>> > | b1 == b2 = Friend
>> > | b1 > b2 = Older
>> > | b1 < b2 = Younger
>> >
>> > How can I fit it?
>> >
>> > Sincerely,
>> >
>> >
>> > Jeon-Young Kang
>>
>> Hello Jeon-Young, I attach a version that compiles. Keep in mind that
>>
>> compare (Person x y) (Person q w) -- this is legal
>>
>> compare Person x y Person q w -- "space" takes precedence over
>> everything,
>> -- so this function has 6 arguments
>> -- instead of the expected 2!
>>
>>
>> ?> Main.compare (Person "cdsac" 1) (Person "cdscasd" 20)
>> Younger
>>
>
>
>
> --
> Department of Geography
> State University of New York at Buffalo
>
> [email protected]
>
> Jeon-Young Kang
>
------------------------------
Message: 6
Date: Wed, 25 Nov 2015 11:39:15 +0000
From: Stephen Renehan <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Simple function comparison
Message-ID:
<CACoC9hAF3a4KRzqz0p6m3D9O4HHTuuGdBD56XZw14S=1urr...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
Hi,
I'm looking to do a comparison between 2 simple functions to see if
they are equivalent but I appear to be running into some problems if
anyone can help.
The two functions I want to compare are f (g a) and g (f a).
I have f defined and g defined as
f :: a -> a
f = undefined
g :: a -> a.
g = undefined
The compiler was complaining about the type signature lacking a
binding so added undefined to get around the error. I understand that
I must be missing something very basic as they look incomparable in
this form. Any suggestions of what changes I should make such a
comparison practical?
Many thanks,
Stephen
--
This email originated from DIT. If you received this email in error, please
delete it from your system. Please note that if you are not the named
addressee, disclosing, copying, distributing or taking any action based on
the contents of this email or attachments is prohibited. www.dit.ie
Is ? ITB?C a th?inig an r?omhphost seo. M? fuair t? an r?omhphost seo tr?
earr?id, scrios de do ch?ras ? le do thoil. Tabhair ar aird, mura t? an
seola? ainmnithe, go bhfuil dianchosc ar aon nochtadh, aon ch?ipe?il, aon
d?ileadh n? ar aon ghn?omh a dh?anfar bunaithe ar an ?bhar at? sa
r?omhphost n? sna hiat?in seo. www.dit.ie
T? ITB?C ag aistri? go Gr?inseach Ghorm?in ? DIT is on the move to
Grangegorman <http://www.dit.ie/grangegorman>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 89, Issue 42
*****************************************