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:  Sankey Diagram with monads (Brandon Allbery)
   2. Re:  Q 2 of 2: GUI and turnkey compiler? (Hans Georg Schaathun)
   3.  help with IO and guards (Miro Karpis)
   4. Re:  help with IO and guards (Bob Ippolito)
   5. Re:  Q 2 of 2: GUI and turnkey compiler? (Gan Uesli Starling)
   6. Re:  Q 2 of 2: GUI and turnkey compiler? (Brandon Allbery)


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

Message: 1
Date: Fri, 31 May 2013 15:37:34 -0400
From: Brandon Allbery <[email protected]>
Subject: Re: [Haskell-beginners] Sankey Diagram with monads
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Message-ID:
        <cakfcl4vu92nfy6-o5wgnsprzd5qu6_gsg8u_rhdktkvrg+-...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Fri, May 31, 2013 at 12:31 PM, Adrian May <[email protected]
> wrote:

> Thanks, but I still don't know how to fix it.
>
> In the meantime, I'm struggling with something more basic. I plan to write
> a basic monad that puts diagrams on top of each other, then I'll let State
> take care of pushing the origin and angle along (turtle style). But I'm
> already stuck on that basic monad.
>

My first question would be: are you sure it's actually a monad? Your
descriptions so far make me think that it quite possibly is not.

-- 
brandon s allbery kf8nh                               sine nomine associates
[email protected]                                  [email protected]
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130531/9209587d/attachment-0001.htm>

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

Message: 2
Date: Fri, 31 May 2013 21:07:08 +0100
From: Hans Georg Schaathun <[email protected]>
Subject: Re: [Haskell-beginners] Q 2 of 2: GUI and turnkey compiler?
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

On Fri, May 31, 2013 at 11:37:47AM -0700, Tim Perry wrote:
> GHC is a compiler. 
>  (...)
> That said, it is *nice* when compilers will statically link your executable. 

Isn't there a linker for that part of the job?

:-)

-- 
:-- Hans Georg



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

Message: 3
Date: Sat, 1 Jun 2013 02:02:40 +0200
From: Miro Karpis <[email protected]>
Subject: [Haskell-beginners] help with IO and guards
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Message-ID:
        <cajnnbxgeekwby6na87pua01hk5ap+17eze84ticnrnvmcta...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Please, I'm trying to do some user user input validation, but it looks like
my  approach is not correct. Here is my code:

textInput :: IO ()
textInput
| dataIn == "bye" = return ()
| otherwise          = textInput
where dataIn <- getLine

the idea is that when user inputs "bye" the program should end/return.
Problem is that I'm getting 'parse error on input `<-'' error. How can I
achieve it?

Another question I have is: how can I have more actions in guard, when the
condition is valid. Something like (write on IO + return if dataIn == "bye):

textInput :: IO ()
textInput
*| dataIn == "bye" = (puStrLn "quitting", return () ) -- *
| otherwise          = textInput
where dataIn <- getLine

Millions of thanks for any kind of input..

Cheers,
Miro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130601/9cf8099f/attachment-0001.htm>

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

Message: 4
Date: Fri, 31 May 2013 17:25:05 -0700
From: Bob Ippolito <[email protected]>
Subject: Re: [Haskell-beginners] help with IO and guards
To: Miro Karpis <[email protected]>,    The Haskell-Beginners
        Mailing List - Discussion of primarily  beginner-level topics related
        to Haskell <[email protected]>
Message-ID:
        <CACwMPm_0+KbH=cRU-GOz=fvav0batfnxy1rwi0dknrxeadj...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Fri, May 31, 2013 at 5:02 PM, Miro Karpis <[email protected]>wrote:

> Please, I'm trying to do some user user input validation, but it looks
> like my  approach is not correct. Here is my code:
>
> textInput :: IO ()
> textInput
> | dataIn == "bye" = return ()
>  | otherwise          = textInput
> where dataIn <- getLine
>
> the idea is that when user inputs "bye" the program should end/return.
> Problem is that I'm getting 'parse error on input `<-'' error. How can I
> achieve it?
>
> Another question I have is: how can I have more actions in guard, when the
> condition is valid. Something like (write on IO + return if dataIn == "bye):
>
> textInput :: IO ()
> textInput
> *| dataIn == "bye" = (puStrLn "quitting", return () ) -- *
> | otherwise          = textInput
>  where dataIn <- getLine
>
> Millions of thanks for any kind of input..
>

Your initial attempt didn't work because the "foo <- bar" syntax is only
available when using a "do block"

A straightforward way to do this without "do block" syntax may look
something like this:

textInput :: IO ()
textInput = getLine >>= go
  where
    go dataIn
      | dataIn == "bye" = putStrLn "quitting" >> return ()
      | otherwise       = textInput

Note that putStrLn actually returns IO (), which is the same thing as
return (), so it is redundant. You can shorten it to this:

textInput :: IO ()
textInput = getLine >>= go
  where
    go dataIn
      | dataIn == "bye" = putStrLn "quitting"
      | otherwise       = textInput

You could do this a bit more compactly by using an anonymous function:

textInput :: IO ()
textInput = getLine >>= dataIn -> if dataIn == "bye" then putStrLn
"quitting" else textInput

With a do block, your example could go something like this. This is very
similar to the above, only using do with "<-" instead of ">>=" and a
function:

textInput :: IO ()
textInput = do
  dataIn <- getLine
  if dataIn == "bye"
    then putStrLn "quitting"
    else textInput

-bob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130531/5589b653/attachment-0001.htm>

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

Message: 5
Date: Fri, 31 May 2013 22:20:39 -0400
From: Gan Uesli Starling <[email protected]>
Subject: Re: [Haskell-beginners] Q 2 of 2: GUI and turnkey compiler?
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

I think I need to define what is meant by turn-key compiler. That is 
what they called it in JForth. In Perl this same feature goes by the 
term "packed archive" and in LabVIEW they call it a "built application".

It is a feature in those languages whereby you can issue an standalone 
*.exe having within itself, complete unto itself, all that is needed to 
run the script, program, application. The output appears as a single 
file to the end user with the expected extension of *.exe but functions 
in fact more like those ZIP installers which also come with *.exe 
extensions. The size will be bloated, since packed archive has within it 
all from the parent language, modules included, that are needful to run 
the script, at least for Perl. For JForth it was much the same. For 
LabVIEW the output of a "build" requires to have the "runtime engine" 
installed, but which, once installed, is good for ALL applictions and 
will run them but not allow editing.

So, it would be something to allow an author to issue programs which 
end-users would NOT have to know anything about Haskell itself and would 
have to, at most, perform a two-step, wholly automatic installation 
procedure. Short of this, anything I might aspire to give away free to 
the public en masse, could not conceivably be written in Haskell. In 
which case, I'll respectfully bow out from endeavoring to learn it 
myself, however useful it serves for many another purpose.



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

Message: 6
Date: Fri, 31 May 2013 22:44:15 -0400
From: Brandon Allbery <[email protected]>
Subject: Re: [Haskell-beginners] Q 2 of 2: GUI and turnkey compiler?
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Message-ID:
        <cakfcl4xtun1u3ec73z8pjrfcjdpffnet4rbtk1asxxnqvuv...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Fri, May 31, 2013 at 10:20 PM, Gan Uesli Starling <[email protected]>wrote:

> So, it would be something to allow an author to issue programs which
> end-users would NOT have to know anything about Haskell itself and would
> have to, at most, perform a two-step, wholly automatic installation
> procedure. Short of this, anything I might aspire to give away free to the
> public en masse, could not conceivably be written in Haskell. In which
> case, I'll respectfully bow out from endeavoring to learn it myself,
> however useful it serves for many another purpose.


Aside from system libraries, if you don't configure your packages to be
dynamic GHC works that way. You can also force system libraries if you use
-static; but note that this also links libc static, which is problematic on
at least Linux and Solaris. (Usually, the only problematic system library
is gmp.)

Note that the gmp case is also not significantly different from any random
Linux program, and you could in fact choose to bundle the appropriate
libgmp.so.whatever with your program and use a wrapper script which sets
LD_LIBRARY_PATH (on Linux or Solaris; DYLD_FALLBACK_LIBRARY_PATH on recent
OS X).

Part of whats throwing you off, I suspect, is that GHC is a native code
compiler. You might want to look at what it takes for applications for
other native compilers, such as C and C++, to bundle necessary libraries.
Perl is an interpreter, and bundling just means including the necessary
modules in a local library and making use of local::lib, or at worst 'use
lib'. It's a much simpler situation than native code compilation. Even in
the case where a .exe is generated for Windows, it's still making use of
interpreted code; Perl cannot be compiled to native code at all sanely. The
.exe instead is instead either a bit like a self-unpacking archive, or a
wrapper which invokes a Perl interpreter on a module tree with various
environment variables and paths set. JForth, similarly, is based on the JVM
instead of native code, and it's trivial to bundle up everything needed in
a jar.

(Apple's done a fair amount of work to make bundling native code easier by
means of special linker paths in application and framework bundles which
both the compile-time ld and the runtime dyld can interpret, but this is of
course not of any use on Windows or Linux.)

-- 
brandon s allbery kf8nh                               sine nomine associates
[email protected]                                  [email protected]
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130531/7111ad13/attachment.htm>

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

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


End of Beginners Digest, Vol 60, Issue 1
****************************************

Reply via email to