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.  How Haskell Fits Into an Operating System / API  Environment
      (Philippe Sismondi)
   2. Re:  How Haskell Fits Into an Operating System / API
      Environment (Magnus Therning)
   3.  HTTP Download -> Save File - non-strict (Dan Krol)
   4. Re:  HTTP Download -> Save File - non-strict (Magnus Therning)
   5. Re:  How Haskell Fits Into an Operating System /  API
      Environment (Heinrich Apfelmus)


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

Message: 1
Date: Sat, 10 Aug 2013 10:22:06 -0400
From: Philippe Sismondi <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] How Haskell Fits Into an Operating System
        / API   Environment
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

I am interested in tracking down discussions on how Haskell fits into an 
operating system environment. That is probably not a very clear question, so 
let me explain.

One of the great obstacles I have faced in using two of my favourite languages 
(Common Lisp and Haskell) for anything practical is that I am constantly 
frustrated by their relationship with the host OS, or perhaps more accurately 
with the APIs provided by the OS.

For example, I tend to program mostly on OS X. I have a reasonable knowledge of 
Cocoa, and can get quite a lot done with Objective-C. So, if I want to use 
Haskell on OS X, I can run off and learn about Haskell's FFI, or some 
hand-rolled widget package, etc. But here is the problem: Cocoa et al provide 
an entire ecosystem that includes data structures, error handling, and so on. 
So, when trying to use Haskell with a GUI, or perhaps to do some audio 
processing, or other things that are provided by the OS X APIs, I feel that I 
am layering two quite incompatible worlds together: Haskell and its host 
environment. 

I ran into the same dilemma with Common Lisp. Clozure Common Lisp provides an 
excellent Cocoa binding. But using it feels (to me) like communications between 
alien races. The OS APIs want to do things the Objective-C way, and that is 
(clearly) not the Haskell or Lisp way.

One soon notices that books on Haskell pay virtually no attention to this 
issue. At least, the ones I have don't.

Maybe what I am really experiencing is that OS X just "wants" to be programmed 
in its native language. I had something of a better feeling about using F# on 
Windows, because that architecture does leverage the native stuff much better.

The upshot is that I remain skeptical that Haskell is actually a practical 
language for many kinds of development.

Can anyone point me to discussions on this? I may be having a dimwitted 
interval here, but I don't know what to search to find this.

- P -


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

Message: 2
Date: Sat, 10 Aug 2013 22:06:02 +0200
From: Magnus Therning <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] How Haskell Fits Into an Operating
        System / API Environment
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

On Sat, Aug 10, 2013 at 10:22:06AM -0400, Philippe Sismondi wrote:
> I am interested in tracking down discussions on how Haskell fits
> into an operating system environment. That is probably not a very
> clear question, so let me explain.
> 
> One of the great obstacles I have faced in using two of my favourite
> languages (Common Lisp and Haskell) for anything practical is that I
> am constantly frustrated by their relationship with the host OS, or
> perhaps more accurately with the APIs provided by the OS.
> 
> For example, I tend to program mostly on OS X. I have a reasonable
> knowledge of Cocoa, and can get quite a lot done with Objective-C.
> So, if I want to use Haskell on OS X, I can run off and learn about
> Haskell's FFI, or some hand-rolled widget package, etc. But here is
> the problem: Cocoa et al provide an entire ecosystem that includes
> data structures, error handling, and so on. So, when trying to use
> Haskell with a GUI, or perhaps to do some audio processing, or other
> things that are provided by the OS X APIs, I feel that I am layering
> two quite incompatible worlds together: Haskell and its host
> environment. 
> 
> I ran into the same dilemma with Common Lisp. Clozure Common Lisp
> provides an excellent Cocoa binding. But using it feels (to me) like
> communications between alien races. The OS APIs want to do things
> the Objective-C way, and that is (clearly) not the Haskell or Lisp
> way.

I'm not sure there are a lot of discussions or texts on this issue,
but maybe you can find some solace in me thinking that this problem
pops up whenever one tries to combine components written in different
languages.  For instance C++ is able to call straight to C libraries,
but that doesn't mean that C APIs fit well into "idiomatic C++" (or
maybe I should say one of the many "idiomatic C++s").  The same goes
for all other combinations I've tried out myself, Python+C,
Python+C++, Java+C, Haskell+C... I'm fairly sure it is the case with
*every* combination.

I'm also fairly sure that the friction becomes higher the more
different the languages are, i.e. combining two procedural (non-OO)
languages is most likely easier than combining a procedural (non-OO)
with an OO language, even if both are imperative.  If the languages
have different paradigms, e.g. imperative vs. functional, the friction
becomes higher still.

> One soon notices that books on Haskell pay virtually no attention to
> this issue. At least, the ones I have don't.

I believe the FFI is touched upon, but providing an idiomatic Haskell
API for a C library is most likely an art (maybe a black one ;) at
this point.  So in short, you are right.  (I'd love to be proven wrong
here and be pointed to some recipe book for how to wrap C in Haskell,
or C in Python, and do it well.)

/M

-- 
Magnus Therning                      OpenPGP: 0xAB4DFBA4 
email: [email protected]   jabber: [email protected]
twitter: magthe               http://therning.org/magnus

I invented the term Object-Oriented, and I can tell you I did not have
C++ in mind.
     -- Alan Kay
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 230 bytes
Desc: not available
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130810/309c4a2c/attachment-0001.sig>

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

Message: 3
Date: Sat, 10 Aug 2013 17:16:58 -0700
From: Dan Krol <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] HTTP Download -> Save File - non-strict
Message-ID:
        <caawrcs_bf6u_3mqwua67d+pct5tpaq5ivvangh0nqw0naqm...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hi,

I'm working on an rss file getter. I was wondering if I could get some help
getting files to download and save without holding the entire file in
memory in between. I chose Conduit's version of SimpleHttp only because it
was recommended, and it was the quickest thing I could get to work
correctly because I was eager to get started on this project, so I'd be
happy to switch.

Here's where I define the download and save functions:

https://github.com/orblivion/feedGetter/blob/master/rss.hs#L107

And here's where I use them, getting multiple at a time with async:

https://github.com/orblivion/feedGetter/blob/master/rss.hs#L208

What happens when I run this is that it outputs that it's "Getting" the
file, waits a while (presumably to download the whole thing), then says
it's "Saving". And I checked the file system, it's not there during the
pause. I'm not entirely sure why. Is it my choice of libraries, or the way
I'm using them? Perhaps something to do with async? I just tried content <-
simpleHttp "http://google.com"; in ghci, and it does pause for a second, so
I'm guessing this is strict from the getgo. But I've done almost no I/O
before.

Is there a straightforward, canonical option? It seems like there perhaps
should be. But if it comes down to using pipes or conduit, what the heck
I'll try it out, I'd like to learn pipes eventually.

Thanks a lot,

Dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130810/640e1198/attachment-0001.html>

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

Message: 4
Date: Sun, 11 Aug 2013 08:30:30 +0200
From: Magnus Therning <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] HTTP Download -> Save File -
        non-strict
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

On Sat, Aug 10, 2013 at 05:16:58PM -0700, Dan Krol wrote:
> Hi,
> 
> I'm working on an rss file getter. I was wondering if I could get
> some help getting files to download and save without holding the
> entire file in memory in between. I chose Conduit's version of
> SimpleHttp only because it was recommended, and it was the quickest
> thing I could get to work correctly because I was eager to get
> started on this project, so I'd be happy to switch.
> 
> Here's where I define the download and save functions:
> 
> https://github.com/orblivion/feedGetter/blob/master/rss.hs#L107
> 
> And here's where I use them, getting multiple at a time with async:
> 
> https://github.com/orblivion/feedGetter/blob/master/rss.hs#L208
> 
> What happens when I run this is that it outputs that it's "Getting"
> the file, waits a while (presumably to download the whole thing),
> then says it's "Saving". And I checked the file system, it's not
> there during the pause. I'm not entirely sure why. Is it my choice
> of libraries, or the way I'm using them? Perhaps something to do
> with async? I just tried content <- simpleHttp "http://google.com";
> in ghci, and it does pause for a second, so I'm guessing this is
> strict from the getgo. But I've done almost no I/O before.
> 
> Is there a straightforward, canonical option? It seems like there
> perhaps should be. But if it comes down to using pipes or conduit,
> what the heck I'll try it out, I'd like to learn pipes eventually.

Michael is very good with documenting his packages, this is what I
found in the docs for http-conduit (http://is.gd/WkDb7G):

  Note: Even though this function returns a lazy bytestring, it does
  not utilize lazy I/O, and therefore the entire response body will
  live in memory. If you want constant memory usage, you'll need to
  use the conduit package and http directly.

/M

-- 
Magnus Therning                      OpenPGP: 0xAB4DFBA4 
email: [email protected]   jabber: [email protected]
twitter: magthe               http://therning.org/magnus

I invented the term Object-Oriented, and I can tell you I did not have
C++ in mind.
     -- Alan Kay
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 230 bytes
Desc: not available
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130811/25aaf61e/attachment-0001.sig>

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

Message: 5
Date: Sun, 11 Aug 2013 10:58:15 +0200
From: Heinrich Apfelmus <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] How Haskell Fits Into an Operating
        System /        API Environment
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8; format=flowed

Philippe Sismondi wrote:
> I am interested in tracking down discussions on how Haskell fits into
> an operating system environment. That is probably not a very clear
> question, so let me explain.
> 
> One of the great obstacles I have faced in using two of my favourite
> languages (Common Lisp and Haskell) for anything practical is that I
> am constantly frustrated by their relationship with the host OS, or
> perhaps more accurately with the APIs provided by the OS.
> 
> For example, I tend to program mostly on OS X. I have a reasonable
> knowledge of Cocoa, and can get quite a lot done with Objective-C.
> So, if I want to use Haskell on OS X, I can run off and learn about
> Haskell's FFI, or some hand-rolled widget package, etc. But here is
> the problem: Cocoa et al provide an entire ecosystem that includes
> data structures, error handling, and so on. So, when trying to use
> Haskell with a GUI, or perhaps to do some audio processing, or other
> things that are provided by the OS X APIs, I feel that I am layering
> two quite incompatible worlds together: Haskell and its host
> environment.
> 
> I ran into the same dilemma with Common Lisp. Clozure Common Lisp
> provides an excellent Cocoa binding. But using it feels (to me) like
> communications between alien races. The OS APIs want to do things the
> Objective-C way, and that is (clearly) not the Haskell or Lisp way.
> 
> One soon notices that books on Haskell pay virtually no attention to
> this issue. At least, the ones I have don't.
> 
> Maybe what I am really experiencing is that OS X just "wants" to be
> programmed in its native language. I had something of a better
> feeling about using F# on Windows, because that architecture does
> leverage the native stuff much better.
> 
> The upshot is that I remain skeptical that Haskell is actually a
> practical language for many kinds of development.
> 
> Can anyone point me to discussions on this? I may be having a
> dimwitted interval here, but I don't know what to search to find
> this.

I'm not entirely sure I understand your question.

The fact that, say, Objective-C uses quite a different way of speech 
than Haskell is not surprising, these are two different languages after 
all. You would have similar problems in an imaginary world where Haskell 
were the norm and Objective-C the exception. If you want to use both at 
once, you have to invest work in building a bridge. For instance, you 
can present Haskell in a more Objective-C-y fashion, or the other way 
round, or some middle ground. That's just how it is and it applies to 
all languages.


Concerning Objective-C specifically, there was a very nice project 
implementing a slick FFI for Cocoa in Haskell. Unfortunately, it has 
been dead for years now.

   http://hoc.sourceforge.net/


Somewhat related, there is actually an (experimental) OS written in 
Haskell, see

    http://stackoverflow.com/a/6638207/403805


In case you're not that interested in integrating with the entire OS, 
but are just looking for a GUI library in Haskell anyway, I would like 
to toot my own horn and point to threepenny-gui, which uses the web 
browser as a display.

   https://github.com/HeinrichApfelmus/threepenny-gui


Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com




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

Subject: Digest Footer

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


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

End of Beginners Digest, Vol 62, Issue 9
****************************************

Reply via email to