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.  (no subject) (Jan Brosius)
   2. Re:  (no subject) (Christopher Done)
   3. Re:  (no subject) (Philipp Schneider)
   4. Re:  code explanation (Michael Orlitzky)
   5. Re:  code explanation (Tom Murphy)
   6. Re:  Understandig types (Jared Hance)


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

Message: 1
Date: Sun, 3 Jul 2011 15:07:11 +0200
From: Jan Brosius <[email protected]>
Subject: [Haskell-beginners] (no subject)
To: [email protected]
Message-ID:
        <CAENB2gWu4mu7-M7pUdi9s5m3n9WBSL66U16XNXi=cmduknb...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hi,

Is there in Haskell a function like unwindprotect in Lisp.

Thanks
Jan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20110703/d6125249/attachment-0001.htm>

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

Message: 2
Date: Sun, 3 Jul 2011 15:13:11 +0200
From: Christopher Done <[email protected]>
Subject: Re: [Haskell-beginners] (no subject)
To: Jan Brosius <[email protected]>
Cc: [email protected]
Message-ID:
        <CAAJHNPBdVJPAz9rMxWAECKC3=w_psppgt5dmlvxj0c1ssu9...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

On 3 July 2011 15:07, Jan Brosius <[email protected]> wrote:
> Hi,
> Is there in Haskell a function like unwindprotect in Lisp.

See the utilities section of Control.Exception:
http://haskell.org/ghc/docs/latest/html/libraries/base/Control-Exception.html#g:16



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

Message: 3
Date: Sun, 03 Jul 2011 15:30:23 +0200
From: Philipp Schneider <[email protected]>
Subject: Re: [Haskell-beginners] (no subject)
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

Hi,

I think you're looking for the function bracket.

See
http://haskell.org/ghc/docs/latest/html/libraries/base/Control-Exception.html#v:bracket

http://book.realworldhaskell.org/read/io-case-study-a-library-for-searching-the-filesystem.html
(Section The acquire-use-release cycle)

Cheers,
Philipp

On 07/03/2011 03:07 PM, Jan Brosius wrote:
> Hi,
>
> Is there in Haskell a function like unwindprotect in Lisp.
>
> Thanks
> Jan
>
>
> _______________________________________________
> 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/20110703/926b145f/attachment-0001.htm>

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

Message: 4
Date: Sun, 03 Jul 2011 09:32:06 -0400
From: Michael Orlitzky <[email protected]>
Subject: Re: [Haskell-beginners] code explanation
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

On 07/02/2011 12:47 PM, [email protected] wrote:
> I'm a beginner, I'd like someone to help me understand a few lines of code
> My questions are:
> 1) Maybe String is an application of the constructor Maybe to the type
> String.
> What does it mean? Is there anything equivalent in the C language?

"Maybe" is the Haskell way to represent a value that might be Nothing
(you can think of Nothing as analogous to C's null). A value of type
(Maybe String) might be a String, or it might be Nothing. You usually
use pattern matching to determine which one you're dealing with before
you try to do anything with the value.

In C, this would be something like checking whether a string pointer is
null before you try to print it.

Homework:

  http://learnyouahaskell.com/making-our-own-types-and-typeclasses

(I recommend the whole book if you have time. A hard copy is available
on Amazon.)


> 2) Is this a function with three arguments?
> *type T = [Char]*
> *type P = (Char, Maybe String)*
> *type Delta = ((Maybe Char, Char), Maybe String)*
> *fromGtoM :: T -> [P] -> [Delta]*

The type signature of this function shows both the arguments and its
return value. To learn more, you should read,

  http://learnyouahaskell.com/higher-order-functions

but basically, you can think of the last value in the type signature
(e.g. [Delta], here) as the return value. The rest are arguments.


> 3) is this a usage of the above mentioned function?
> *fromGtoM t p = terminalRules ++ varRules*

We don't have enough information, but it doesn't look right.


> I dont'see why the function has three arguments but then only
> two are used t p.
> 4) what does *++* mean ?

The "++" function just concatenates two lists. Strings are lists, so you
might call it string concatenation too depending on the context.



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

Message: 5
Date: Sun, 3 Jul 2011 11:41:39 -0400
From: Tom Murphy <[email protected]>
Subject: Re: [Haskell-beginners] code explanation
To: [email protected]
Cc: [email protected]
Message-ID:
        <cao9q0twzh52sm37tw+haj96rrpcdvnzxaqui4396ebfxhmj...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

On 7/2/11, [email protected] <[email protected]> wrote:

> 4) what does ++ mean ?
>

When you want to know what a function does, a good place to look is
http://www.haskell.org/hoogle/

Tom



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

Message: 6
Date: Sun, 3 Jul 2011 13:39:14 -0400
From: Jared Hance <[email protected]>
Subject: Re: [Haskell-beginners] Understandig types
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

On Sat, Jul 02, 2011 at 12:00:44PM -0700, Michael Xavier wrote:
> From: Michael Xavier <[email protected]>
> To: [email protected]
> Cc: [email protected]
> Date: Sat, 2 Jul 2011 12:00:44 -0700
> Subject: Re: [Haskell-beginners] Understandig types
> 
> I do agree you should look at the tutorial but to answer your questions, see
> below:
> 
> 1) what's the difference between these two code statements? I'm
> > convinced they should be the same
> >
> > type T = [Char]
> > type CurrentValue = Char
> >
> >
> You could think of the type keyword as aliasing an existing type to one that
> you name. For instance, T can now be used interchangeably with the [Char]
> type, like in a type declaration:
> 
> upcase :: [Char] -> [Char]
> can be:
> upcase :: T -> T
> 
> and they would mean the same thing. You do this usually for the sake of
> documentation, where the alias you are creating is more readable than that
> which it aliases.
> 
> [Char] means an array of Chars. String, for example is I believe defined as:
> type String = [Char]

No. [Char] is a list, not array, of Char. That is, something like

data List a = Cons a (List a) | Empty

> 
> 
> > 2) What is Maybe String?
> >
> >
> Maybe String is a datatype that could be 1 of 2 things, a String or Nothing.
> Maybe is used a lot of the time for computations that may fail, such as
> looking for a needle in a haystack:

To elaborate: It is

data Maybe a = Just a | Nothing

in ADT form.



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

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


End of Beginners Digest, Vol 37, Issue 6
****************************************

Reply via email to