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:  literate programming (Andres L?h)
   2. Re:  Cross-platform .hs files on Linux and        Windows (Vinay Sajip)
   3.  profiling a program that writes midi events (Dennis Raddle)
   4.  Noob question.(I'm trying        'http://learnyouahaskell.com'
      tutorial) (Mait)
   5. Re:  Noob question.(I'm trying    'http://learnyouahaskell.com'
      tutorial) (Jakub Oboza)
   6. Re:  Noob question.(I'm trying 'http://learnyouahaskell.com'
      tutorial) (aditya siram)
   7. Re:  Noob question.(I'm trying 'http://learnyouahaskell.com'
      tutorial) (Kyle Murphy)
   8. Re:  Cross-platform .hs files on Linux and        Windows (Marius Ghita)


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

Message: 1
Date: Mon, 16 Apr 2012 23:01:21 +0200
From: Andres L?h <andres.l...@googlemail.com>
Subject: Re: [Haskell-beginners] literate programming
To: Francisco Gutierrez <fgutiers2...@yahoo.com>
Cc: "beginners@haskell.org" <beginners@haskell.org>
Message-ID:
        <caljd_v6ukpvsxrqh54ppwpicannc4cj7ug7kzl59zsbv1ir...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Hi.

> I am just toying around with Cordelia Hall and John O'Donnell excellent book
> on dicrete mathematics with Haskell. Well, they have a program, stdm,
> to accompany the book. It happens that it is in literate style. In theory,
> this should be very easy to work with, but after saving it with lhs
> extension, I try
> to load it, without success. Could somebody out there help me with this?

You should say where you got the file, and explain what "without
success" means. Also, it's relevant which version of GHC you're using
(assuming you're using GHC). I googled and downloaded this file

  http://www.dcs.gla.ac.uk/~jtod/discrete-mathematics/Stdm.lhs

I can successfully load it in both ghc-7.0.4 and ghc-7.4.1 by saying

  ghci -XHaskell98 Stdm.lhs

The -XHaskell98 specifies that the file is written in Haskell98 rather
than the more recent Haskell2010 standard. If you're using an older
ghc version (ghc-6.12.3, for example), this flag isn't required.

HTH,
  Andres



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

Message: 2
Date: Mon, 16 Apr 2012 21:11:33 +0000 (UTC)
From: Vinay Sajip <vinay_sa...@yahoo.co.uk>
Subject: Re: [Haskell-beginners] Cross-platform .hs files on Linux and
        Windows
To: beginners@haskell.org
Message-ID: <loom.20120416t230729-...@post.gmane.org>
Content-Type: text/plain; charset=us-ascii

Lorenzo Bolla <lbolla <at> gmail.com> writes:

> 
> Check this out:
>
http://stackoverflow.com/questions/6818031/use-shebang-hashbang-in-windows-command-prompt
> 

Thanks, but that link just leads either to answers saying it can't be done, or
information about using assoc and ftype to associate e.g. .hs files with
runhaskell. That's not the crux of the problem: the crux is that runhaskell on
Linux will run .hs files with a #!/usr/bin/env runhaskell (even though that's
not a valid line in Haskell), whereas runhaskell.exe on Windows will try to
parse that first line using the Haskell parser, even though it's not valid
Haskell (the Linux version presumably skips that first line).

Regards,

Vinay Sajip




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

Message: 3
Date: Mon, 16 Apr 2012 14:47:19 -0700
From: Dennis Raddle <dennis.rad...@gmail.com>
Subject: [Haskell-beginners] profiling a program that writes midi
        events
To: Haskell Beginners <beginners@haskell.org>
Message-ID:
        <CAKxLvoqHP=hmZfQbm0Eq7Jd=3mnr1u6qmn-nysohrghmpjr...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

I want to profile a program, but it's not the usual kind of "run once, it
completes" program. It computes a bunch of midi events and writes them to a
MIDI port via the Sound.PortMidi module. It waits between events so that
each one happens in the proper place in the music. And the program must not
exit while it is writing events.

When I run it, it takes about ten seconds until the music starts, so it
must be doing most of the computation then. But it takes several minutes as
it plays music.

How would I profile this kind of program?

One possibility is to modify it a bit so it computes all the midi events
but doesn't send them, and just exits. However, I have to make sure it
actually computes the events all the way (due to language laziness). If I
don't write the events to PortMidi, then they are never used. I'm not sure
on how to ensure an expression is completely evaluated if it never used.

Dennis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20120416/45712973/attachment-0001.htm>

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

Message: 4
Date: Tue, 17 Apr 2012 06:50:27 +0900
From: Mait <matte...@gmail.com>
Subject: [Haskell-beginners] Noob question.(I'm trying
        'http://learnyouahaskell.com' tutorial)
To: beginners@haskell.org
Message-ID: <4f8c9423.2000...@gmail.com>
Content-Type: text/plain; charset=UTF-8; format=flowed

ENV

Ubuntu 12.04
haskell-platform/precise uptodate 2012.1.0.0~debian

ghci --version
The Glorious Glasgow Haskell Compilation System, version 7.4.1

I've tried all day with,
'Learn You a Haskell for Great Good!'
http://learnyouahaskell.com/

Very attractive book. I'm really enjoying this book.

Anyway I have one question,

Why I can't declare func type like books?

I got always error about 'lacks an accompanying binding', like this,

Prelude> :l baby.hs
[1 of 1] Compiling Main             ( baby.hs, interpreted )

baby.hs:32:1:
     The type signature for take' lacks an accompanying binding
Failed, modules loaded: none.

Here is codepad link,
http://codepad.org/ttZRBpkL

Thanks.



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

Message: 5
Date: Mon, 16 Apr 2012 22:55:57 +0100
From: Jakub Oboza <jakub.ob...@gmail.com>
Subject: Re: [Haskell-beginners] Noob question.(I'm trying
        'http://learnyouahaskell.com' tutorial)
To: Mait <matte...@gmail.com>
Cc: beginners@haskell.org
Message-ID: <e9d85ced-d759-47c5-9e8d-372497ba2...@gmail.com>
Content-Type: text/plain; charset=us-ascii

Because GHC is limited

in GHC you cant do 

double a = a * a

you have to put into let
like this

let double a = a * a 

Cheers!

On 16 Apr 2012, at 22:50, Mait wrote:

> ENV
> 
> Ubuntu 12.04
> haskell-platform/precise uptodate 2012.1.0.0~debian
> 
> ghci --version
> The Glorious Glasgow Haskell Compilation System, version 7.4.1
> 
> I've tried all day with,
> 'Learn You a Haskell for Great Good!'
> http://learnyouahaskell.com/
> 
> Very attractive book. I'm really enjoying this book.
> 
> Anyway I have one question,
> 
> Why I can't declare func type like books?
> 
> I got always error about 'lacks an accompanying binding', like this,
> 
> Prelude> :l baby.hs
> [1 of 1] Compiling Main             ( baby.hs, interpreted )
> 
> baby.hs:32:1:
>    The type signature for take' lacks an accompanying binding
> Failed, modules loaded: none.
> 
> Here is codepad link,
> http://codepad.org/ttZRBpkL
> 
> Thanks.
> 
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://www.haskell.org/mailman/listinfo/beginners




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

Message: 6
Date: Mon, 16 Apr 2012 17:29:38 -0500
From: aditya siram <aditya.si...@gmail.com>
Subject: Re: [Haskell-beginners] Noob question.(I'm trying
        'http://learnyouahaskell.com' tutorial)
To: Jakub Oboza <jakub.ob...@gmail.com>
Cc: beginners@haskell.org
Message-ID:
        <CAJrReyg0AGrJsJNW_n9EFh2SCbj4P0gd9AQmPZ2pT5LVRvbq=w...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

It's not working because you don't have a definition for take'. If you
want to fill it in later you can just do:

take' = undefined

-deech

On Mon, Apr 16, 2012 at 4:55 PM, Jakub Oboza <jakub.ob...@gmail.com> wrote:
> Because GHC is limited
>
> in GHC you cant do
>
> double a = a * a
>
> you have to put into let
> like this
>
> let double a = a * a
>
> Cheers!
>
> On 16 Apr 2012, at 22:50, Mait wrote:
>
>> ENV
>>
>> Ubuntu 12.04
>> haskell-platform/precise uptodate 2012.1.0.0~debian
>>
>> ghci --version
>> The Glorious Glasgow Haskell Compilation System, version 7.4.1
>>
>> I've tried all day with,
>> 'Learn You a Haskell for Great Good!'
>> http://learnyouahaskell.com/
>>
>> Very attractive book. I'm really enjoying this book.
>>
>> Anyway I have one question,
>>
>> Why I can't declare func type like books?
>>
>> I got always error about 'lacks an accompanying binding', like this,
>>
>> Prelude> :l baby.hs
>> [1 of 1] Compiling Main ? ? ? ? ? ? ( baby.hs, interpreted )
>>
>> baby.hs:32:1:
>> ? ?The type signature for take' lacks an accompanying binding
>> Failed, modules loaded: none.
>>
>> Here is codepad link,
>> http://codepad.org/ttZRBpkL
>>
>> Thanks.
>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners@haskell.org
>> http://www.haskell.org/mailman/listinfo/beginners
>
>
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://www.haskell.org/mailman/listinfo/beginners



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

Message: 7
Date: Mon, 16 Apr 2012 18:39:16 -0400
From: Kyle Murphy <orc...@gmail.com>
Subject: Re: [Haskell-beginners] Noob question.(I'm trying
        'http://learnyouahaskell.com' tutorial)
To: Jakub Oboza <jakub.ob...@gmail.com>
Cc: beginners@haskell.org
Message-ID:
        <ca+y6jcwcgnrv+rwtum_yofanfu8o9motvvd+vp+eo-4a+oj...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

As aditya pointed out, you need to declare any function you use (or provide
a type signature of) but don't explicitly define as undefined. That will
allow the code to compile but will throw an error when any undefined
functions are called.

I want to address what Jakub said however as I think it's somewhat
misleading.

On Mon, Apr 16, 2012 at 17:55, Jakub Oboza <jakub.ob...@gmail.com> wrote:
> Because GHC is limited
>
> in GHC you cant do
>
> double a = a * a
>
> you have to put into let
> like this
>
> let double a = a * a
>
> Cheers!

It might be more accurate to say that GHCi (the interactive shell, not GHC
the compiler) makes some assumptions about what you're typing in order to
make it more useful. For example, GHCi assumes that you're always typing
something of the form:

IO a

This is why you need to change most "normal" haskell expressions into let
bindings, because then you're explicitly telling GHCi that you don't want
to interpret what you're typing as an IO expression. The reason it makes
that assumption is because often times you really do want it interpreted as
IO as in the example:

ghci> putStrLn $ "Example " ++ show 5
Example 5

It also makes assumptions about types of constants that GHC normally does
not. Furthermore it allows rebinding of declarations as in:

ghci> let x = 5
ghci> x
5
ghci> let x = 6
ghci> x
6

You need to be careful with that though because something like this will
not behave as you might expect:

ghci> let x = 5
ghci> let f = x * x
ghci> f
25
ghci> let x = 10
ghci> f
25

GHCi is very powerful and a great way to experiment and test code out, but
it's important to understand some of the assumptions it makes in order to
be more productive in the majority of cases. On Linux it's often best to
start with an empty hs file, load that into GHCi, and then use :edit to
open it in an editor and fill the contents out. You can then save and exit
your editor and it will return you to the GHCi prompt where you can
experiment and inspect the code you've written.

-R. Kyle Murphy
--
Curiosity was framed, Ignorance killed the cat.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20120416/79062b89/attachment-0001.htm>

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

Message: 8
Date: Tue, 17 Apr 2012 03:31:09 +0300
From: Marius Ghita <mhi...@gmail.com>
Subject: Re: [Haskell-beginners] Cross-platform .hs files on Linux and
        Windows
To: Vinay Sajip <vinay_sa...@yahoo.co.uk>
Cc: beginners@haskell.org
Message-ID:
        <CAB7aqhh8mV0M5dnfPYb6vL-qD0hz1+BZZP-CWWkp3oJ=jLHX=a...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

And thats expected given than the shebang is *nix specific.

On Tue, Apr 17, 2012 at 12:11 AM, Vinay Sajip <vinay_sa...@yahoo.co.uk>wrote:

> Lorenzo Bolla <lbolla <at> gmail.com> writes:
>
> >
> > Check this out:
> >
>
> http://stackoverflow.com/questions/6818031/use-shebang-hashbang-in-windows-command-prompt
> >
>
> Thanks, but that link just leads either to answers saying it can't be
> done, or
> information about using assoc and ftype to associate e.g. .hs files with
> runhaskell. That's not the crux of the problem: the crux is that
> runhaskell on
> Linux will run .hs files with a #!/usr/bin/env runhaskell (even though
> that's
> not a valid line in Haskell), whereas runhaskell.exe on Windows will try to
> parse that first line using the Haskell parser, even though it's not valid
> Haskell (the Linux version presumably skips that first line).
>
> Regards,
>
> Vinay Sajip
>
>
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>



-- 
Google+: https://plus.google.com/111881868112036203454
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20120417/09c9dacc/attachment.htm>

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

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


End of Beginners Digest, Vol 46, Issue 25
*****************************************

Reply via email to