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: Beginners Digest, Vol 30, Issue 17 (Brent Yorgey)
2. Parse error. Please, Help me. (Sok H. Chang)
3. Re: Parse error. Please, Help me. (Magnus Therning)
4. Re: Parse error. Please, Help me. (aditya siram)
5. Equivalent of inheritance in Haskell (C K Kashyap)
6. Re: Equivalent of inheritance in Haskell (Paul Sargent)
7. Enum/Bounded question (Patrick LeBoutillier)
8. Re: Equivalent of inheritance in Haskell (Antoine Latter)
----------------------------------------------------------------------
Message: 1
Date: Mon, 13 Dec 2010 06:36:42 -0500
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] Beginners Digest, Vol 30, Issue 17
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Sun, Dec 12, 2010 at 03:09:44PM -0800, Russ Abbott wrote:
> Is there no way to make the class approach (or something like it) work?
> That's how I would do it in Java--define the component as an interface as
> far as the structure is concerned and then define the component itself to
> implement the interface.
Not really. Although in a sense, my version with a separate Types
module feels somehow morally equivalent; the Types module provides the
"interface" and then the other modules are defined in terms of that.
You could use a type class if you really wanted more of a "behavioral"
interface, but you would still have to put the type class in a
separate module to avoid circularity.
-Brent
> *
> -- Russ*
>
>
> On Sun, Dec 12, 2010 at 3:00 AM, <[email protected]> wrote:
>
> > 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: Linking modules (Brent Yorgey)
> >
> >
> > ----------------------------------------------------------------------
> >
> > Message: 1
> > Date: Sat, 11 Dec 2010 15:37:23 -0500
> > From: Brent Yorgey <[email protected]>
> > Subject: Re: [Haskell-beginners] Linking modules
> > To: [email protected]
> > Message-ID: <[email protected]>
> > Content-Type: text/plain; charset=iso-8859-1
> >
> > On Sat, Dec 11, 2010 at 08:56:23PM +0100, Chadda? Fouch? wrote:
> > > On Sat, Dec 11, 2010 at 7:37 PM, Russ Abbott <[email protected]>
> > wrote:
> > > > I have two modules Structure and Component. ?Module Structure defines
> > > > ?? ? data Structure = Component ...
> > > > Module Component defines
> > > > ?? ?data Component = ...
> > > > I would like Structure to import Component. ?But Component
> > > > includes?functions?that take a Structure as an argument. So I have (or
> > would
> > > > like) something like this organization.
> > > >
> > > > [snip]
> > > >
> > > > The functions in Component are really very Component related and should
> > not
> > > > be moved to Structure. So how can I set up this circular relationship?
> > >
> > > GHC allows you to compile mutually recursive modules, see
> > >
> > http://www.haskell.org/ghc/docs/latest/html/users_guide/separate-compilation.html#mutual-recursion
> > > for how to do it.
> >
> > Yes, this is possible, but it has always seemed sort of fragile and
> > ugly to me. Another suggestion is to put the definitions of the
> > Structure and Component data types into a separate module called
> > Types, and then import Types into both the Structure module (which
> > defines functions over Structures) and the Component module (which
> > defines functions over Components). Then no circularity is needed.
> >
> > -Brent
> >
> >
> >
> > ------------------------------
> >
> > _______________________________________________
> > Beginners mailing list
> > [email protected]
> > http://www.haskell.org/mailman/listinfo/beginners
> >
> >
> > End of Beginners Digest, Vol 30, Issue 17
> > *****************************************
> >
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
------------------------------
Message: 2
Date: Mon, 13 Dec 2010 23:29:08 +0900
From: "Sok H. Chang" <[email protected]>
Subject: [Haskell-beginners] Parse error. Please, Help me.
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="utf-8"
Hello, everyone.
I write my second code... but when I compile this, I got an error... (My
first code works. of course, at that time, I got an indentation error, but I
could fix it.)
Haskell>ghc --make Temp.hs -o Temp.exe
[1 of 1] Compiling Main ( Temp.hs, Temp.o )
Temp.hs:7:0: parse error (possibly incorrect indentation)
Temp.hs is made using by jEdit on Window XP.
I install Haskell Platform.
code is ...
import System.IO
import System.Random
let sentenceAry = []
main :: IO ()
main = do inh <- openFile "c:\\Documents and
Settings\\shaegis\\inputFile.txt" ReadMode
outh <- openFile "c:\\Documents and Settings\\shaegis\\outputFile.txt"
WriteMode
mainloop inh outh
hClose inh
hClose outh
mainloop :: Handle -> Handle -> IO ()
mainloop inh outh = do ineof <- hIsEOF inh
if ineof
then do hPutStrLn outh inpStr
return ()
else do inpStr <- hGetLine inh
let sentenceAry = inpStr : []
mainloop inh outh
Please, help me.
Thank you.
Sincerely, Sok Chang
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20101213/1f1b1ba3/attachment-0001.htm>
------------------------------
Message: 3
Date: Mon, 13 Dec 2010 14:34:11 +0000
From: Magnus Therning <[email protected]>
Subject: Re: [Haskell-beginners] Parse error. Please, Help me.
To: "Sok H. Chang" <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=UTF-8
On Mon, Dec 13, 2010 at 14:29, Sok H. Chang <[email protected]> wrote:
> Hello, everyone.
> I write my second code... but when I compile this, I got an error... (My
> first code works. of course, at that time, I got an indentation error, but I
> could fix it.)
> Haskell>ghc --make Temp.hs -o Temp.exe
> [1 of 1] Compiling Main ? ? ? ? ? ? ( Temp.hs, Temp.o )
> Temp.hs:7:0: parse error (possibly incorrect indentation)
>
> Temp.hs is made using by jEdit on Window XP.
> I install Haskell Platform.
> code is ...
> import System.IO
> import System.Random
> let sentenceAry = []
That 'let' isn't necessary.
> main :: IO ()
> main = do inh <- openFile "c:\\Documents and
> Settings\\shaegis\\inputFile.txt" ReadMode
> outh <- openFile "c:\\Documents and Settings\\shaegis\\outputFile.txt"
> WriteMode
> mainloop inh outh
> hClose inh
> hClose outh
> mainloop :: Handle -> Handle -> IO ()
> mainloop inh outh = do ineof <- hIsEOF inh
> if ineof
> then do hPutStrLn outh inpStr
> return ()
> else do inpStr <- hGetLine inh
> let sentenceAry = inpStr : []
> mainloop inh outh
> Please, help me.
> Thank you.
>
> Sincerely, Sok Chang
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
--
Magnus Therning ? ? ? ? ? ? ? ? ? ? ?OpenPGP: 0xAB4DFBA4
email: [email protected] ? jabber: [email protected]
twitter: magthe ? ? ? ? ? ? ? http://therning.org/magnus
------------------------------
Message: 4
Date: Mon, 13 Dec 2010 08:35:37 -0600
From: aditya siram <[email protected]>
Subject: Re: [Haskell-beginners] Parse error. Please, Help me.
To: "Sok H. Chang" <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
At the top level there shouldn't be any "let ...." so change your:
> let sentenceAry = []
to:
> sentenceAry = []
-deech
On Mon, Dec 13, 2010 at 8:29 AM, Sok H. Chang <[email protected]> wrote:
> Hello, everyone.
> I write my second code... but when I compile this, I got an error... (My
> first code works. of course, at that time, I got an indentation error, but I
> could fix it.)
> Haskell>ghc --make Temp.hs -o Temp.exe
> [1 of 1] Compiling Main ? ? ? ? ? ? ( Temp.hs, Temp.o )
> Temp.hs:7:0: parse error (possibly incorrect indentation)
>
> Temp.hs is made using by jEdit on Window XP.
> I install Haskell Platform.
> code is ...
> import System.IO
> import System.Random
> let sentenceAry = []
> main :: IO ()
> main = do inh <- openFile "c:\\Documents and
> Settings\\shaegis\\inputFile.txt" ReadMode
> outh <- openFile "c:\\Documents and Settings\\shaegis\\outputFile.txt"
> WriteMode
> mainloop inh outh
> hClose inh
> hClose outh
> mainloop :: Handle -> Handle -> IO ()
> mainloop inh outh = do ineof <- hIsEOF inh
> if ineof
> then do hPutStrLn outh inpStr
> return ()
> else do inpStr <- hGetLine inh
> let sentenceAry = inpStr : []
> mainloop inh outh
> Please, help me.
> Thank you.
>
> Sincerely, Sok Chang
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
------------------------------
Message: 5
Date: Mon, 13 Dec 2010 22:46:27 +0530
From: C K Kashyap <[email protected]>
Subject: [Haskell-beginners] Equivalent of inheritance in Haskell
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Hi,
In oops, one can do reuse code by extending a parent class. What is
the equivalent in Haskell?
Regards,
Kashyap
------------------------------
Message: 6
Date: Mon, 13 Dec 2010 17:40:14 +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 13 Dec 2010, at 17:16, C K Kashyap wrote:
> In oops, one can do reuse code by extending a parent class. What is
> the equivalent in Haskell?
There isn't an equivalent as Haskell doesn't have classes (type classes are
different). There's other ways to do things, but without knowing what you're
doing it's difficult to point to anything.
------------------------------
Message: 7
Date: Mon, 13 Dec 2010 12:49:39 -0500
From: Patrick LeBoutillier <[email protected]>
Subject: [Haskell-beginners] Enum/Bounded question
To: beginners <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Hi,
I'm looking for a function to make a list of all the constructors in a
type that derives both Enum and Bounded, i.e.
enumAll :: (Bounded a, Enum a) => [a]
enumAll = [minBound .. maxBound]
Does this function exists in the standard modules?
Patrick
--
=====================
Patrick LeBoutillier
Rosem?re, Qu?bec, Canada
------------------------------
Message: 8
Date: Mon, 13 Dec 2010 11:50:34 -0600
From: Antoine Latter <[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=UTF-8
In OO languages I try not to use inheritance just because I want
re-use - I tend to lean more towards having an instance of class A
contain or wrap around an instance of class B - I will only use
inheritance if A truly is a more specific version of B. Even then I
try to make sure there aren't clearer ways of expressing what I want.
This approach applies perfectly well to types in Haskell - compound
types can be composed of values of other types.
But there is not a way to easily say (in Haskell) "type A is
everything that type B is plus these other things here ...". Haskell
is not an OO language.
Antoine
On Mon, Dec 13, 2010 at 11:16 AM, C K Kashyap <[email protected]> wrote:
> Hi,
> In oops, one can do reuse code by extending a parent class. What is
> the equivalent in Haskell?
> Regards,
> Kashyap
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 30, Issue 19
*****************************************