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:  book question (Mike Meyer)
   2. Re:  Do I understand this well (Roelof Wobben)
   3. Re:  Doing IO in terms of Arrow (Haisheng Wu)
   4. Re:  A first try (Manfred Lotz)
   5. Re:  A first try (Yitzchak Gale)
   6. Re:  A first try (David Place)
   7. Re:  DSL for Android development (Mike Meyer)
   8. Re:  A first try (Yitzchak Gale)


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

Message: 1
Date: Mon, 27 Jun 2011 12:46:42 -0400
From: Mike Meyer <[email protected]>
Subject: Re: [Haskell-beginners] book question
To: Raphael P?bst <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8

On Mon, 27 Jun 2011 11:21:37 +0200
Raphael P?bst <[email protected]> wrote:

> I used Real World Haskell
> Http:/book.realworldhaskell.org
> and was very happy with it.
> There's also Learn You A Haskell For Great Good
> http://www.learnyouahaskell.com
> which is probably funnier, but I can't tell you much more about it.
> For both it is helpful to have some experience with programming in
> genereal, but these are the first that came to mind.

The online version of Real World Haskell has a comments facility,
which people use to post solutions and discussions of the problems in
the book. I've found those to be invaluable.

On the other hand, the examples in the that book are apparently
executed when rendered (which is sorta cool), and some of them no
longer work because of changes in the haskell environment they are run
in. So you get error messages instead of example output.

    <mike
-- 
Mike Meyer <[email protected]>             http://www.mired.org/
Independent Software developer/SCM consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org



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

Message: 2
Date: Mon, 27 Jun 2011 16:52:10 +0000
From: Roelof Wobben <[email protected]>
Subject: Re: [Haskell-beginners] Do I understand this well
To: <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"


Oke

 

It worked now.

A bumpy ride to begin something new with.

 

Roelof



----------------------------------------
> From: [email protected]
> Date: Mon, 27 Jun 2011 23:51:45 +0800
> Subject: Re: [Haskell-beginners] Do I understand this well
> To: [email protected]
> CC: [email protected]
>
> Top-level bindings are done in ghci with let:
>
> let (x, y) = addVectors (3.0, 4.5, -3.4, -5.6)
>
> On Mon, Jun 27, 2011 at 11:49 PM, Roelof Wobben <[email protected]> wrote:
> >
> >
> >
> > ________________________________
> >> Date: Mon, 27 Jun 2011 16:14:28 +0100
> >> Subject: Re: [Haskell-beginners] Do I understand this well
> >> From: [email protected]
> >> To: [email protected]
> >>
> >> No.
> >>
> >> You are onfusing defining a function with using it.
> >>
> >>
> >> addVectors (x1, y1) (x2, y2) = (x1 + x2, y1 + y2)
> >>
> >> defines the function addVectors
> >>
> >> (x, y) = addVectors (3.0, 4.5, -3.4, -5.6)
> >>
> >> calls the function, and binds x and y to the components of the result
> >> (pattern matching).
> >>
> >> Alternatively:
> >>
> >> fst . addVectors (3.0, 4.5, -3.4, -5.6)
> >>
> >> will return the x-compnent of the result (by composing functions)
> >>
> >
> >
> > Oke,
> >
> >
> >
> > I understand that I think
> >
> > But when I ghci I enter :
> >
> >
> > (x, y) = addVectors (3.0, 4.5, -3.4, -5.6)
> >
> >
> >
> >
> >
> > after I made a file with the file defenition.
> >
> > I get this error :
> >
> >
> >
> > :1:7 parse error on input =
> >
> >
> >
> > So something is not right here.
> >
> >
> >
> > Roelof
> >
> >
> > _______________________________________________
> > Beginners mailing list
> > [email protected]
> > http://www.haskell.org/mailman/listinfo/beginners
> >                                       


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

Message: 3
Date: Tue, 28 Jun 2011 01:03:36 +0800
From: Haisheng Wu <[email protected]>
Subject: Re: [Haskell-beginners] Doing IO in terms of Arrow
To: Ertugrul Soeylemez <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

You find point I need the correct type signatures.
And seems like it is (missed IO in your description)
Kleisli IO FilePath [FilePath]

Thanks a lot!

-Haisheng


On Tue, Jun 28, 2011 at 12:38 AM, Ertugrul Soeylemez <[email protected]> wrote:

> Haisheng Wu <[email protected]> wrote:
>
> >   I'm wondering if it is possible doing IO in terms of Arrow.
> >   I got a function search all files under directory recursively and
> > I'd like to refartoring using Arrow terms.
>
> Yes, it's possible using Kleisli, but it's not very convenient, because
> you need the Kleisli wrapper around everything.  Also usually there is
> really little reason to do that, because monads are more expressive.
> For example they allow you to encode computations with only outputs
> directly, without wrapping them in a computation, which takes a stub
> argument.
>
>
> >   I tried to define a function like below but failed.
> >   isDirExist = Kleisli doesDirectoryExist
> >
> >   Do I need to define a instance for IO to be Arrow? Or is there any
> > existing solutions?
>
> No, the needed instances are already there, but you need to change your
> type signatures:
>
>    myGetFilesInDir :: Kleisli FilePath [FilePath]
>
>
> Greets,
> Ertugrul
>
>
> --
> nightmare = unsafePerformIO (getWrongWife >>= sex)
> http://ertes.de/
>
>
>
> _______________________________________________
> 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/20110628/5145cdeb/attachment-0001.htm>

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

Message: 4
Date: Mon, 27 Jun 2011 18:27:03 +0200
From: Manfred Lotz <[email protected]>
Subject: Re: [Haskell-beginners] A first try
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII

On Mon, 27 Jun 2011 11:35:24 -0400
David Place <[email protected]> wrote:

> 
> 
> On Jun 27, 2011, at 9:58 AM, Manfred Lotz wrote:
> 
> > Thanks a lot for the suggestion. Works fine.
> > 
> > I only tried deepseq because my first try with seq 
> > 
> > let content = xml `seq` parseXMLDoc xml
> > 
> > didn't work. 
> 
> 
> Have you considered using ByteStrings for your application.  There,
> hGetContents is strict.  Also, you will benefit from more efficient
> string operations.

Yes, I thought about it but didn't dig deeper because Text.XML.Light
wants a string as input and I didn't find a conversion. But now I found
toString in  Text.XML.Light.UTF8 so I tried it. 

It doesn't make much difference in performance because the xml files
are pretty small. However, using the strict functions makes the code a
bit less esoteric. :-)




-- 
Thanks,
Manfred





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

Message: 5
Date: Mon, 27 Jun 2011 20:45:08 +0300
From: Yitzchak Gale <[email protected]>
Subject: Re: [Haskell-beginners] A first try
To: David Place <[email protected]>
Cc: Heinrich Apfelmus <[email protected]>,
        [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

David Place wrote:
>>> Suppose the file is only partially demanded as in the case I quoted earlier.
>>>
>>> print10 =
>>> ? ? do
>>> ? ? ? contents <- withFile "/usr/share/dict/words" ReadMode (\h -> 
>>> hGetContents h)
>>> ? ? ? print $ take 10 contents
>>>
>>> The file would never be closed.

I wrote:
>> I tried it - it does close the file.

> II'm not sure what you mean. ?Did you create a new version of withFile that 
> behaves
> as Heinrich suggested? ?If so, please post its definition.

I just loaded Heinrich's withFile' in GHCi and ran it:

*WithFile> withFile' "/usr/share/dict/words" (print . take 10 . words)
open
["A","A's","AOL","AOL's","Aachen","Aachen's","Aaliyah","Aaliyah's","Aaron","Aaron's"]
close



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

Message: 6
Date: Mon, 27 Jun 2011 13:47:13 -0400
From: David Place <[email protected]>
Subject: Re: [Haskell-beginners] A first try
To: [email protected]
Cc: Heinrich Apfelmus <[email protected]>,
        [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

On Jun 27, 2011, at 1:45 PM, Yitzchak Gale wrote:

> David Place wrote:
>>>> Suppose the file is only partially demanded as in the case I quoted 
>>>> earlier.
>>>> 
>>>> print10 =
>>>>     do
>>>>       contents <- withFile "/usr/share/dict/words" ReadMode (\h -> 
>>>> hGetContents h)
>>>>       print $ take 10 contents
>>>> 
>>>> The file would never be closed.
> 
> I wrote:
>>> I tried it - it does close the file.
> 
>> II'm not sure what you mean.  Did you create a new version of withFile that 
>> behaves
>> as Heinrich suggested?  If so, please post its definition.
> 
> I just loaded Heinrich's withFile' in GHCi and ran it:
> 
> *WithFile> withFile' "/usr/share/dict/words" (print . take 10 . words)
> open
> ["A","A's","AOL","AOL's","Aachen","Aachen's","Aaliyah","Aaliyah's","Aaron","Aaron's"]
> close

Thanks.  I understand now.


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

Message: 7
Date: Mon, 27 Jun 2011 13:47:39 -0400
From: Mike Meyer <[email protected]>
Subject: Re: [Haskell-beginners] DSL for Android development
To: Sean Charles <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII

On Mon, 27 Jun 2011 15:04:55 +0100
Sean Charles <[email protected]> wrote:

> As a yet to be published iPhone hacker, now somewhat saddened by the 
> AppStore bouncers, I've turned to Android. I have a lot of Java and J2ME 
> experience but only eight months with Haskell. I hate java. The JVM is 
> awesome. Clojure is wish-fulfillment for Android right now.

There are other choices. Have you looked into Scala or Groovy?

> So... where would be a good place to start with a DSL that could produce 
> Java code as its output? This is new to me! I've written simple lexers 
> and parsers and I know the ropes on that front but I don't know haskell 
> well enough yet to know how to go about it. I am thinking that I'd need 
> to create data types for the major classes, or maybe not, if i can 
> produce my own abstraction that generated multiple classes in the output 
> etc and so i descend into confusion about where to start!

This seems like an odd approach.

> I did consider writing a "true" language that will code-generate
> java instead of a DSL, that's still in my mind too.

If by this, you mean generating JVM byte codes directly, I'd be
interested in why this is a second choice behind generating Java?
Generating JVM shouldn't be noticeably harder, should result in better
code, can be moved to Android, and is the path taken by other
languages running on the JVM.

Sorry I can't help directly - but I'm also interested in Android
development and hate Java (and find the infrastructure around it
disappointing.)

        <mike
-- 
Mike Meyer <[email protected]>             http://www.mired.org/
Independent Software developer/SCM consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org



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

Message: 8
Date: Mon, 27 Jun 2011 20:55:14 +0300
From: Yitzchak Gale <[email protected]>
Subject: Re: [Haskell-beginners] A first try
To: David Place <[email protected]>
Cc: Heinrich Apfelmus <[email protected]>,
        [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

David Place wrote:
> It's hGetContents that bothers me. ?I have found that friends who I have
>?convinced to learn Haskell always trip over this right away. They want
> to write a simple program that processes a file and immediately get
> tangled up with lazy IO and looking up the definition of deepseq.
> It's kind of embarrassing.

There's nothing to be embarrassed about. Haskell is lazy by default.
That is certainly much different than what most people are
used to. So it needs to be explained to beginners. It's the same
for IO laziness as for pure laziness.

I'd much rather explain that, which fits in with the whole
style of Haskell, than to have to explain Iteratees to a newcomer.

In any case, you can't expect the switch from Python to Haskell
to go nearly as smoothly as the switch from Perl to Python.
The paradigm shift is much bigger.

-Yitz



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

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


End of Beginners Digest, Vol 36, Issue 74
*****************************************

Reply via email to