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: Equivalent of inheritance in Haskell (Paul Sargent)
2. Re: Equivalent of inheritance in Haskell (Richard Mittel)
3. Include external libs on cabal project (Marco De Oliveira)
4. haskell / prolog (dan portin)
----------------------------------------------------------------------
Message: 1
Date: Mon, 20 Dec 2010 13:18:36 +0000
From: Paul Sargent <[email protected]>
Subject: Re: [Haskell-beginners] Equivalent of inheritance in Haskell
To: C K Kashyap <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On 14 Dec 2010, at 03:10, C K Kashyap wrote:
> If I understand you right .. you'd build a 'Man' type and 'Woman' type
> by using a 'Person' type. Lets say, there is a function called getName
> that is Person -> String
In this case you can just make a new data type:
data Person = Man {name :: String, age :: Int} | Woman {name :: String}
marry :: Person -> Person -> String
marry (Man m _) (Woman w) = m ++ ", " ++ w ++ ", I know pronounce you
Man and Wife"
marry a@(Woman _) b@(Man _ _) = (name b) ++ ", " ++ (name a) ++ ", I know
pronounce you Man and Wife"
marry _ _ = error "Not in these parts!"
The clumsy second line is just to show the function <name :: Person -> String>
which accesses the name of both men and women.
The function "age" also takes a Person as it's argument, but in this case, if
you ask a Woman her age things won't end well.
(..and forgive the example. I was finding it hard to come up with something
that would be different for men and women without getting crude.)
This isn't the same as the classes you're describing in OO land though. Here,
Man and Woman are data constructor functions which both return the type Person.
There's no inheritance here, so it's *not* possible to have a Mammal data type
of which Person's are a member, and so by extension Man & Woman.
Man and Woman are *not* data types themselves, so I can't write a function
<giveBirth :: Woman -> Person>. I'd have to write a <giveBirth :: Person ->
Person> and fail if it was passed a Man.
I personally find this type of construct very useful, but you just have to be
careful to make sure you check to make sure an item can support the functions
you want before calling them (e.g. 'age' above). It's not caught by the type
checker at compile time, so it'll only be caught at run time and it causes an
exception.
------------------------------
Message: 2
Date: Mon, 20 Dec 2010 10:06:43 -0500
From: Richard Mittel <[email protected]>
Subject: Re: [Haskell-beginners] Equivalent of inheritance in Haskell
To: Paul Sargent <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
I'm afraid that apologies and humor did not make you seem less "crude," as
you put it, and your language is too apt to be misunderstood by homosexuals
and women as unwelcoming. So please exercise more care when posting.
On Mon, Dec 20, 2010 at 8:18 AM, Paul Sargent <[email protected]> wrote:
>
> On 14 Dec 2010, at 03:10, C K Kashyap wrote:
>
> > If I understand you right .. you'd build a 'Man' type and 'Woman' type
> > by using a 'Person' type. Lets say, there is a function called getName
> > that is Person -> String
>
> In this case you can just make a new data type:
>
> data Person = Man {name :: String, age :: Int} | Woman {name :: String}
>
> marry :: Person -> Person -> String
> marry (Man m _) (Woman w) = m ++ ", " ++ w ++ ", I know pronounce
> you Man and Wife"
> marry a@(Woman _) b@(Man _ _) = (name b) ++ ", " ++ (name a) ++ ", I
> know pronounce you Man and Wife"
> marry _ _ = error "Not in these parts!"
>
> The clumsy second line is just to show the function <name :: Person ->
> String> which accesses the name of both men and women.
>
> The function "age" also takes a Person as it's argument, but in this case,
> if you ask a Woman her age things won't end well.
>
> (..and forgive the example. I was finding it hard to come up with something
> that would be different for men and women without getting crude.)
>
> This isn't the same as the classes you're describing in OO land though.
> Here, Man and Woman are data constructor functions which both return the
> type Person. There's no inheritance here, so it's *not* possible to have a
> Mammal data type of which Person's are a member, and so by extension Man &
> Woman.
>
> Man and Woman are *not* data types themselves, so I can't write a function
> <giveBirth :: Woman -> Person>. I'd have to write a <giveBirth :: Person ->
> Person> and fail if it was passed a Man.
>
> I personally find this type of construct very useful, but you just have to
> be careful to make sure you check to make sure an item can support the
> functions you want before calling them (e.g. 'age' above). It's not caught
> by the type checker at compile time, so it'll only be caught at run time and
> it causes an exception.
>
>
> _______________________________________________
> 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/20101220/371d8729/attachment-0001.htm>
------------------------------
Message: 3
Date: Mon, 20 Dec 2010 23:59:54 +0100
From: Marco De Oliveira <[email protected]>
Subject: [Haskell-beginners] Include external libs on cabal project
To: Haskell liste de diffusion <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"; Format="flowed"
Hi,
I try to include an external lib (and C files that I made) on my cabal
file and when I launch "configure" I have errors.
I have added on my file:
extra-libraries: "winscard"
include-dirs: "C:\Program Files\Microsoft SDKs\Windows\v7.1\Include"
extra-lib-dirs: "C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib"
and it fails because of the space on the path. (see logs)
Is the syntax correct?
What I have to change so that cabal can understand the space on
directory path?
Thanks for help
Cabal version: 1.8.0.6
log after "runhaskell setup.lhs configure -v3"
("C:\\Program Files\\Haskell
Platform\\2010.2.0.0\\mingw\\bin\\gcc.exe",["C:\\Us
ers\\E6400\\AppData\\Local\\Temp\\8104.c","-o","C:\\Users\\E6400\\AppData\\Local
\\Temp\\8104","-D__GLASGOW_HASKELL__=612","-Idist\\build\\autogen","-ISmartCard/
libpcsc/inc",*"-I\"C:\\Program","-IFiles\\Microsoft","-ISDKs\\Windows\\v7.1\\Incl
ude\"*","-I.","-IC:\\Program Files\\Haskell
Platform\\2010.2.0.0\\lib\\base-4.2.0
.2\\include","-IC:\\Program Files\\Haskell
Platform\\2010.2.0.0\\lib/include","-
IC:\\Program Files\\Haskell
Platform\\2010.2.0.0\\lib/include","-lwinscard",*"-L\
"C:\\Program","-LFiles\\Microsoft","-LSDKs\\Windows\\v7.1\\Lib\"*","-LC:\\Program
Files\\Haskell Platform\\2010.2.0.0\\lib\\base-4.2.0.2","-LC:\\Program
Files\\H
askell Platform\\2010.2.0.0\\lib\\integer-gmp-0.2.0.1","-LC:\\Program
Files\\Has
kell Platform\\2010.2.0.0\\lib\\ghc-prim-0.2.0.0","-LC:\\Program
Files\\Haskell
Platform\\2010.2.0.0\\lib","-LC:\\Program Files\\Haskell
Platform\\2010.2.0.0\\l
ib/gcc-lib","-LC:\\Program Files\\Haskell Platform\\2010.2.0.0\\lib"])
C:\Program Files\Haskell Platform\2010.2.0.0\mingw\bin\gcc.exe returned
ExitFailure 1 with error message:
C:\Program Files\Haskell Platform\2010.2.0.0\mingw\bin\ld.exe: cannot find
-lwinscard
collect2: ld returned 1 exit status
("C:\\Program Files\\Haskell
Platform\\2010.2.0.0\\mingw\\bin\\gcc.exe",["C:\\Us
ers\\E6400\\AppData\\Local\\Temp\\8104.c","-o","C:\\Users\\E6400\\AppData\\Local
\\Temp\\8104","-lwinscard","*-L\"C:\\Program","-LFiles\\Microsoft","-LSDKs\\Windo
ws\\v7.1\\Lib\"",*"-LC:\\Program Files\\Haskell
Platform\\2010.2.0.0\\lib\\base-4
.2.0.2","-LC:\\Program Files\\Haskell
Platform\\2010.2.0.0\\lib\\integer-gmp-0.2
.0.1","-LC:\\Program Files\\Haskell
Platform\\2010.2.0.0\\lib\\ghc-prim-0.2.0.0"
,"-LC:\\Program Files\\Haskell Platform\\2010.2.0.0\\lib","-LC:\\Program
Files\\
Haskell Platform\\2010.2.0.0\\lib/gcc-lib","-LC:\\Program Files\\Haskell
Platfor
m\\2010.2.0.0\\lib"])
C:\Program Files\Haskell Platform\2010.2.0.0\mingw\bin\gcc.exe returned
ExitFailure 1 with error message:
C:\Program Files\Haskell Platform\2010.2.0.0\mingw\bin\ld.exe: cannot find
-lwinscard
collect2: ld returned 1 exit status
("C:\\Program Files\\Haskell
Platform\\2010.2.0.0\\mingw\\bin\\gcc.exe",["C:\\Us
ers\\E6400\\AppData\\Local\\Temp\\8104.c","-o","C:\\Users\\E6400\\AppData\\Local
\\Temp\\8104","-lwinscard","-L\"C:\\Program","-LFiles\\Microsoft","-LSDKs\\Windo
ws\\v7.1\\Lib\"","-LC:\\Program Files\\Haskell
Platform\\2010.2.0.0\\lib\\base-4
.2.0.2","-LC:\\Program Files\\Haskell
Platform\\2010.2.0.0\\lib\\integer-gmp-0.2
.0.1","-LC:\\Program Files\\Haskell
Platform\\2010.2.0.0\\lib\\ghc-prim-0.2.0.0"
,"-LC:\\Program Files\\Haskell Platform\\2010.2.0.0\\lib","-LC:\\Program
Files\\
Haskell Platform\\2010.2.0.0\\lib/gcc-lib","-LC:\\Program Files\\Haskell
Platfor
m\\2010.2.0.0\\lib"])
C:\Program Files\Haskell Platform\2010.2.0.0\mingw\bin\gcc.exe returned
ExitFailure 1 with error message:
C:\Program Files\Haskell Platform\2010.2.0.0\mingw\bin\ld.exe: cannot find
-lwinscard
collect2: ld returned 1 exit status
("C:\\Program Files\\Haskell
Platform\\2010.2.0.0\\mingw\\bin\\gcc.exe",["C:\\Us
ers\\E6400\\AppData\\Local\\Temp\\8104.c","-o","C:\\Users\\E6400\\AppData\\Local
\\Temp\\8104","-c","-D__GLASGOW_HASKELL__=612","-Idist\\build\\autogen","-ISmart
Card/libpcsc/inc",*"-I\"C:\\Program","-IFiles\\Microsoft","-ISDKs\\Windows\\v7.1\
\Include\*"","-I.","-IC:\\Program Files\\Haskell
Platform\\2010.2.0.0\\lib\\base-
4.2.0.2\\include","-IC:\\Program Files\\Haskell
Platform\\2010.2.0.0\\lib/includ
e","-IC:\\Program Files\\Haskell Platform\\2010.2.0.0\\lib/include"])
Setup.lhs: Missing dependency on a foreign library:
* Missing C library: winscard
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20101220/b50ab8e4/attachment-0001.htm>
------------------------------
Message: 4
Date: Mon, 20 Dec 2010 17:54:12 -0800
From: dan portin <[email protected]>
Subject: [Haskell-beginners] haskell / prolog
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
I recently discovered that class and instance declarations in Haskell are
Horn clauses. So I encoded the arithmetic operations from the first chapter
of *Art of Prolog* into Haskell, in the standar
fac(0,s(0)).
fac(s(N),F) :- fac(N,X), mult(s(N),X,F).
class Fac x y | x -> y
instance Fac Z (S Z)
instance (Fac n x, Mult (S n) x f) => Fac (S n) f
I don't understand, however, to make Haskell instantiate values for
variables in a proof. I.e., I don't understand what the Haskell equivalent
of
?- fac(X,Y)
would be for some value of X.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20101220/6aa06d7f/attachment.htm>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 30, Issue 39
*****************************************