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:  Book on formal methods? (Wojciech Jedynak)
   2. Re:  functional parser type error (Brent Yorgey)
   3. Re:  computing multiple attributes in Happy (damodar kulkarni)
   4. Re:  functional parser type error (Stephen Tetley)
   5.  Understanding yampas par and dpSwitch (Nathan H?sken)


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

Message: 1
Date: Wed, 4 Apr 2012 18:48:15 +0200
From: Wojciech Jedynak <wjedy...@gmail.com>
Subject: Re: [Haskell-beginners] Book on formal methods?
To: C Gosch <ch.go...@googlemail.com>
Cc: beginners@haskell.org
Message-ID:
        <caotugqs5ckmxa79t_tgqmfwehqahdlo5vy7mmfsp4ci2bxa...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

2012/4/4 C Gosch <ch.go...@googlemail.com>:
> Hi there,
>
> I suspect that some here may be experts in formal methods. Can you
> recommend a book on formal methods
> (for software engineering)? I do not know about formal methods so far,
> I can take some theory, and in a book I would like to have
> some examples and practical issues explained as well as theoretical stuff.
> Any recommendations?

I'm not sure if that's what you wanted, but you may enjoy working
through the Software Foundations online textbook
(http://www.cis.upenn.edu/~bcpierce/sf/).
It's has a lot of hands on exercises in the Coq proof assistant (which
it introduced from scratch).

Greetings,
Wojciech



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

Message: 2
Date: Wed, 4 Apr 2012 13:31:13 -0400
From: Brent Yorgey <byor...@seas.upenn.edu>
Subject: Re: [Haskell-beginners] functional parser type error
To: beginners@haskell.org
Message-ID: <20120404173113.ga18...@seas.upenn.edu>
Content-Type: text/plain; charset=utf-8

On Wed, Apr 04, 2012 at 10:54:45AM +0100, felipe zapata wrote:
> Hi,
> The parser is defined
> 
> *type Parser a = String ? [(a, String)]*
> *
> *
> But for me it is not pretty clear, why i need to
> make Parser a newtype instead of working
> with this one.

In order to use do-notation, Parser has to be an instance of Monad.
However, ((->) String) is already an instance of Monad, and it's not
the instance you want for Parser.  There cannot be two instances for
the same type, so you must wrap it in a newtype in order to make a
different instance.

The other option is to just implement your own operators

(>==) :: Parser a -> (a -> Parser b) -> Parser b
returnP :: a -> Parser a

and use those directly, though then you cannot use do-notation.

-Brent



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

Message: 3
Date: Thu, 5 Apr 2012 00:11:06 +0530
From: damodar kulkarni <kdamodar2...@gmail.com>
Subject: Re: [Haskell-beginners] computing multiple attributes in
        Happy
To: kak dod <kak.dod2...@gmail.com>
Cc: beginners@haskell.org
Message-ID:
        <cad5hsypyvhayu5zaqnzj1ompqxku_+15c_o62gdb-f3qgkk...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hello,
See the following code. It allows you to compute multiple attributes and
access them too. I don't know a better and simpler method than this to
serve this purpose. Waiting for inputs from experts.
---------------------------------
{
module BitsParser (parse) where
test = parse "1011\n"

-- how to write the list attribute to a file here?
test2 = writeFile "testOutFile" (show $ snd test)

data Dirs = MyLeft | MyRight deriving Show
fun a b = a^b
}

%tokentype { Char }

%token minus { '-' }
%token plus  { '+' }
%token one   { '1' }
%token zero  { '0' }
%token newline { '\n' }

%attributetype { Attrs }
%attribute value { (Integer, [Dirs]) }
%attribute pos   { Int }
%attribute list   { [Dirs] }

%name parse start

%%

start
   : num newline { $$ = $1 }

num
   : bits        { $$ = $1       ; $1.pos = 0 ; $1.list = [] }
   | plus bits   { $$ = $2       ; $2.pos = 0 ; $2.list = [] }
   | minus bits  { $$ = (negate (fst $2), snd $2) ; $2.pos = 0 ; $2.list =
[] }

bits
   : bit         { $$ = $1
                 ; $1.pos = $$.pos ; $1.list =  $$.list
                 }

   | bits bit    { $$ = myComputeAttrFun $1 $2; $$.list = $1.list ++ $2.list
                 ; $1.pos = $$.pos + 1
                 ; $2.pos = $$.pos
                 }

bit
   : zero        { $$ = (0, [MyLeft]) ; $$.list = [MyLeft] }
   | one         { $$ = (fun 2 ($$.pos), [MyRight])  ; $$.list = [MyRight] }

{
myComputeAttrFun a b = (c, d)
 where
  c = fst a + fst b
  d = snd a ++ snd b

happyError = error "parse error"
}
---------------------------------

-- 
Thanks and regards,
-Damodar Kulkarni
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20120405/d20abbb3/attachment-0001.htm>

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

Message: 4
Date: Thu, 5 Apr 2012 07:25:58 +0100
From: Stephen Tetley <stephen.tet...@gmail.com>
Subject: Re: [Haskell-beginners] functional parser type error
Cc: beginners@haskell.org
Message-ID:
        <cab2tprbkk8dw_epex47zvx9yhssyjv4qypj-ukmjp9r_9fa...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

There is working code to accompany the book on Graham Hutton's website
that wraps Parser as a newtype.

http://www.cs.nott.ac.uk/~gmh/book.html
http://www.cs.nott.ac.uk/~gmh/Parsing.lhs

Graham makes a brief comment about the difference at the end of the
parsing chapter.

On 4 April 2012 18:31, Brent Yorgey <byor...@seas.upenn.edu> wrote:

> In order to use do-notation, Parser has to be an instance of Monad.
> However, ((->) String) is already an instance of Monad, and it's not
> the instance you want for Parser. ?There cannot be two instances for
> the same type, so you must wrap it in a newtype in order to make a
> different instance.



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

Message: 5
Date: Thu, 05 Apr 2012 11:09:31 +0200
From: Nathan H?sken <nathan.hues...@posteo.de>
Subject: [Haskell-beginners] Understanding yampas par and dpSwitch
To: beginners@haskell.org
Message-ID: <4f7d614b.6090...@posteo.de>
Content-Type: text/plain; charset=ISO-8859-1

Hi,

I am currently working my way through the paper "Function Reactive
Programming Continued", which is about yampa.

On page 55 (page 5 in the pdf) "par" with the signature:

par :: Functor col => (forall sf . (a -> col sf -> col (b, sf)))
  -> col (SF b c)
  -> SF a (col c)

is introduced.
So the resulting signal function (of type SF a (col c)) takes its input
(of type a) and puts it into the first argument of par together with its
second argument (col (SF b c)) to receive a collection of input/signal
pairs (col (b, sf)). Correct?
My questions:

1. Shouldn't be the signature of the first argument be:
  a -> col (SF b c) -> col (b, (SF b c))
I mean it receives the second argument of par as its second argument?!?

2. When the collection of input signal/pairs is received (col (b, sf)),
the b is applied to sf, correct? Why not directly return the result of
this application?

I hope I was able to state clear enough questions ...
Thanks!
Nathan



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

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


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

Reply via email to