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:  Cross-platform .hs files on Linux and        Windows (Marius Ghita)
   2. Re:  Cross-platform .hs files on Linux and        Windows (Vinay Sajip)
   3. Re:  Cross-platform .hs files on Linux    and     Windows
      (Henk-Jan van Tuyl)
   4. Re:  profiling a program that writes midi events
      (Benjamin Edwards)
   5. Re:  Cross-platform .hs files on Linux and        Windows
      (Brandon Allbery)
   6.  A question of program style (Michael Alan Dorman)
   7. Re:  Cross-platform .hs files on Linux    and     Windows (Vinay Sajip)


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

Message: 1
Date: Tue, 17 Apr 2012 13:51:34 +0300
From: Marius Ghita <[email protected]>
Subject: Re: [Haskell-beginners] Cross-platform .hs files on Linux and
        Windows
To: Vinay Sajip <[email protected]>
Cc: [email protected]
Message-ID:
        <CAB7aqhj5QWWBoD4sioTUq=n9cvmctgatrqcdd+rzbeth2f6...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

http://en.wikipedia.org/wiki/Shebang_%28Unix%29

when it occurs as the first two characters on the first line of a text
file. In this case, the program
loader<http://en.wikipedia.org/wiki/Loader_%28computing%29>in
Unix-like <http://en.wikipedia.org/wiki/Unix-like> operating systems parses
the rest of the first line as an interpreter
directive<http://en.wikipedia.org/wiki/Interpreter_directive>and
invokes the program specified after the character sequence with any
command line options specified as parameters. The name of the file being
executed is passed as the final argument.


As you can see this is not something an interpreter is supposed to do, the
responsability is delegated to the OS's program loader. You could emulate
this under Windows, but I suppose you would be using cygwin or something
similar.

On Tue, Apr 17, 2012 at 11:13 AM, Vinay Sajip <[email protected]>wrote:

> Marius Ghita <mhitza <at> gmail.com> writes:
>
> > And thats expected given than the shebang is *nix specific.
>
> Perhaps not unexpected, but not necessary either. I may be wrong, but it
> seems
> reasonable to assume there's a common code base for the Haskell Platform
> for
> Linux and Windows versions. Presumably there's code for the parser to the
> skip
> shebang line on Linux - there's no reason why it couldn't do the same on
> Windows. As it is, it's just an unhelpful impediment to having
> cross-platform
> scripts (unless there's a good reason for it - I couldn't think of one).
>
> Coincidentally, I am working on functionality which brings shebang line
> processing to Windows, primarily for Python scripts but it also works with
> other
> scripting languages (like Perl). That's not why I posted this, though - I
> was
> just given a set of scripts and want to use them on Windows without
> changing
> them just for this.
>
> Regards,
>
> Vinay Sajip
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> 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/43d66853/attachment-0001.htm>

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

Message: 2
Date: Tue, 17 Apr 2012 11:06:45 +0000 (UTC)
From: Vinay Sajip <[email protected]>
Subject: Re: [Haskell-beginners] Cross-platform .hs files on Linux and
        Windows
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

Marius Ghita <mhitza <at> gmail.com> writes:

> http://en.wikipedia.org/wiki/Shebang_%28Unix%29when it occurs as the first two
characters on the first line of a text file. In this case, the program loader in
Unix-like operating systems parses the rest of the first line as an interpreter
directive
>  and invokes the program specified after the character sequence with any
>  command line options specified as parameters. The name of the file 
> being executed is passed as the final argument.
> 
> As you can see this is not something an interpreter is supposed to do, the
> responsability is delegated to the OS's program loader. You could emulate
> this under Windows, but I suppose you would be using cygwin or something
> similar.

Yes, but on Linux, if you have an executable script hello.hs like this:

#!/usr/bin/env runhaskell
main = putStrLn "Hello, world!"

then when you invoke it as 

$ ./hello.hs

the shell opens the file and looks for a shebang line, finds it, interprets it,
and then calls e.g.

/usr/bin/runhaskell hello.hs

which then parses that file, skipping the shebang line, and produces the
expected result.

On Windows, even if we arrange for the same thing to be done at the OS level,
the operation would fail, because the Windows version of runhaskell does not
skip the shebang line, but tries to parse it as Haskell source.

I'm not saying runhaskell needs to do anything more than skip a shebang line, on
Windows, if it sees one. Otherwise, you can't have cross-platform scripts on
Windows and Linux.

Regards,

Vinay Sajip




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

Message: 3
Date: Tue, 17 Apr 2012 18:23:08 +0200
From: "Henk-Jan van Tuyl" <[email protected]>
Subject: Re: [Haskell-beginners] Cross-platform .hs files on Linux      and
        Windows
To: [email protected], "Vinay Sajip" <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes

On Tue, 17 Apr 2012 13:06:45 +0200, Vinay Sajip <[email protected]>  
wrote:

> I'm not saying runhaskell needs to do anything more than skip a shebang  
> line, on
> Windows, if it sees one. Otherwise, you can't have cross-platform  
> scripts on
> Windows and Linux.


On my Windows XP system, the shebang line is ignored:

HashBang.hs:
----?---------
#!/usr/bin/env runhaskell

main = print "Hello!"
----?---------

> runhaskell HashBang.hs
"Hello!"

> which runhaskell.exe
C:\Program Files\Haskell Platform\2011.4.0.0\bin\runhaskell.exe

Regards,
Henk-Jan van Tuyl


-- 
http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
Haskell programming
--



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

Message: 4
Date: Tue, 17 Apr 2012 10:38:22 -0600
From: Benjamin Edwards <[email protected]>
Subject: Re: [Haskell-beginners] profiling a program that writes midi
        events
To: Dennis Raddle <[email protected]>
Cc: Haskell Beginners <[email protected]>
Message-ID:
        <CAN6k4ng8rmCa_49hQNdqUKAbid8RjzGTsT6yWZ41N-M+=bo...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Consider the criterion package + the modifications you suggested. Criterion
comes with useful functions for ensuring that you evaluate expressions
correctly.

Ben

On 16 April 2012 15:47, Dennis Raddle <[email protected]> wrote:

> 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
>
> _______________________________________________
> 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/20120417/855d0138/attachment-0001.htm>

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

Message: 5
Date: Tue, 17 Apr 2012 13:33:23 -0400
From: Brandon Allbery <[email protected]>
Subject: Re: [Haskell-beginners] Cross-platform .hs files on Linux and
        Windows
To: Vinay Sajip <[email protected]>
Cc: [email protected]
Message-ID:
        <cakfcl4xko6sdhbk_vujeu3g9sj_f5tuwjzutvwm+z_zbqei...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Tue, Apr 17, 2012 at 07:06, Vinay Sajip <[email protected]> wrote:

> the shell opens the file and looks for a shebang line, finds it,
> interprets it,
>

The shell does not; the kernel does.  (You *will* see it documented in some
shells... as something they will try if the kernel-based one fails.  Are
you still running 2.9BSD?)

-- 
brandon s allbery                                      [email protected]
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20120417/75b1c2c5/attachment-0001.htm>

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

Message: 6
Date: Tue, 17 Apr 2012 13:47:57 -0400
From: Michael Alan Dorman <[email protected]>
Subject: [Haskell-beginners] A question of program style
To: Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain

Hey, Haskellers,

I've started writing my first non-toy program in Haskell [1], and things
are starting to click, at least a little bit---I find myself working
around the periphery, building functions that perform particular
operations, testing them in ghci, then figuring out how to link them up.
I at least don't feel perpetually stupid any more.

Anyway, I find myself with a couple of questions.  The first, I guess,
is one of style: One Big Monad, or Several Smaller Monads?

I gather a lot of programs create a big RWST IO (or something of that
ilk) that sits at the heart of the action, and then thread that through
the whole program.

However, because I am developing in little pieces, I found myself
writing, for instance, a routine that used a WriterT IO to find all the
.info files in the directory and grab their contents and returning them
as a [(filename,contents)], which I could then parse and act upon.  I'm
thinking of doing roughly the same thing for the processing of scraping
web information---creating a separate WriterT IO that goes and grabs the
content and delivers it back for parsing.

Is there a consensus that one approach is better than the other?  I
guess I feel like doing it this way is really pushing me to isolate my
imperative vs. pure code, but then, it's all feeding back to processes
running in the IO monad anyway, so am I just being prissy?  Are people
likely to look at my code and wonder Just What The Hell Is Going On?

The second question is one of libraries, I guess.  The process I've
spec'd consists of several fairly discrete operations that have a couple
of paths through them, some of which are recursive.

For instance, if you're given a project name on the command line, you
need to hit the web site, scrape some info, get the source, unpack, walk
and parse the contents, and then generate the debian files...but if
you're called without a project name (to make updating easy), you need
to check the current dir to walk and parse the contents, figure out your
project name and version, *then* hit the website, scrape some info,
check the version numbers, perhaps get the source and unpack in which
case you need to walk and parse the contents again, then finally
generate the debian files.

When I implemented this in Perl, I actually used lazy attributes on a
central object to make most of these processing dependencies implicit
rather than explicit.  It seems like this should be even easier in
Haskell, so I was wondering if there was a component out there already
that made it easy to express these sorts of dependencies to be "solved"?

I appreciate any suggestions or guidance.

Thanks,

Mike.

1. The program is one for generating the Debian packaging files for
Drupal modules (yes, I know one already exists, I've already
re-implemented it once in Perl, so this will actually be version #3),
which is an easily explained task which nonetheless hits a lot of
capabilities (http, html parsing, untar/gz ing, reading and parsing
files, generating files from templates, etc) I would like to explore.



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

Message: 7
Date: Tue, 17 Apr 2012 19:24:27 +0000 (UTC)
From: Vinay Sajip <[email protected]>
Subject: Re: [Haskell-beginners] Cross-platform .hs files on Linux      and
        Windows
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8

Henk-Jan van Tuyl <hjgtuyl <at> chello.nl> writes:

> 
> On my Windows XP system, the shebang line is ignored:
> 
> HashBang.hs:
> ----?---------
> #!/usr/bin/env runhaskell
> 
> main = print "Hello!"
> ----?---------
> 
> > runhaskell HashBang.hs
> "Hello!"
> 

Thank you for this information! I installed the platform on Windows XP
(32-bit), and I get the same result as you. The machine where I was having
the problems was a Windows 7 machine (64-bit), though I used the same
Haskell Platform installer on both.

Perhaps it's a Windows 7 issue, or a 32-bit vs. 64-bit issue. I'll try on a
different Windows 7 machine.

It's good to know that scripts are meant to be cross-platform on Linux and
Windows.

Regards,

Vinay Sajip




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

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


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

Reply via email to