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: Understanding syntax problems (aditya siram) 2. Re: Understanding syntax problems (Stephen Tetley) 3. Re: Understanding syntax problems (Nathan Huesken) 4. Re: Understanding syntax problems (Daniel Fischer) 5. Re: Understanding syntax problems (aditya siram) 6. Re: Understanding syntax problems (Daniel Fischer) 7. profiling weirdness? (Thomas) 8. Re: profiling weirdness? (Daniel Fischer) 9. Compiling Test.hs from reactive-fieldtrip (Nathan Huesken) 10. Re: Compiling Test.hs from reactive-fieldtrip (aditya siram) ---------------------------------------------------------------------- Message: 1 Date: Tue, 8 Jun 2010 12:49:23 -0500 From: aditya siram <aditya.si...@gmail.com> Subject: Re: [Haskell-beginners] Understanding syntax problems To: Nathan Huesken <hask...@lonely-star.org> Cc: Biginners Haskell Mailinglist <beginners@haskell.org> Message-ID: <aanlktin_so3wbct5wc-egl6zztuehndlfpgjliws-...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 A "type" can be both a synonym for both another type or a function. For example: type ProcessIntList = [Int] -> [Int] add_one :: ProcessIntList add_one = map ((+) 1) is the same as: add_one :: [Int] -> [Int] add_one = map ((+) 1) -deech On 6/8/10, Nathan Huesken <hask...@lonely-star.org> wrote: > Hi, > > Reading this: > http://netsuperbrain.com/blog/posts/introducing-reactive-events/ > > I stumble upon this: > > type BellMachine = Event () -> Event () > > Google did not tell me, what this means. > I understand > > type BellMachine = Event() > > but the rest is completely strange to me. > > What does it mean or where can I find out? > > Thanks! > Nathan > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners > ------------------------------ Message: 2 Date: Tue, 8 Jun 2010 18:52:20 +0100 From: Stephen Tetley <stephen.tet...@gmail.com> Subject: Re: [Haskell-beginners] Understanding syntax problems To: Nathan Huesken <hask...@lonely-star.org> Cc: Biginners Haskell Mailinglist <beginners@haskell.org> Message-ID: <aanlktinem8wd8yyrwwsqn-7gruvsvkmt_ve7rq2de...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Hi This is a typo - caused in the translation to HTML: type BellMachine = Event () -> Event () A Bell Machine is a function from Event to Event. Representing state machines as functions from their input to their output is quite a common pattern in Haskell. Best wishes Stephen ------------------------------ Message: 3 Date: Tue, 8 Jun 2010 13:58:32 -0400 From: Nathan Huesken <hask...@lonely-star.org> Subject: Re: [Haskell-beginners] Understanding syntax problems To: Biginners Haskell Mailinglist <beginners@haskell.org> Message-ID: <20100608135832.455fa...@samzwo.tch.harvard.edu> Content-Type: text/plain; charset=US-ASCII Well, that makes complete sense. Just out of curiosity, is it my browser or a problem with the site? Regards, Nathan On Tue, 8 Jun 2010 18:52:20 +0100 Stephen Tetley <stephen.tet...@gmail.com> wrote: > Hi > > This is a typo - caused in the translation to HTML: > > type BellMachine = Event () -> Event () > > A Bell Machine is a function from Event to Event. > > Representing state machines as functions from their input to their > output is quite a common pattern in Haskell. > > > Best wishes > > Stephen > ------------------------------ Message: 4 Date: Tue, 8 Jun 2010 20:00:50 +0200 From: Daniel Fischer <daniel.is.fisc...@web.de> Subject: Re: [Haskell-beginners] Understanding syntax problems To: beginners@haskell.org Message-ID: <201006082000.51147.daniel.is.fisc...@web.de> Content-Type: text/plain; charset="iso-8859-1" On Tuesday 08 June 2010 17:14:19, Nathan Huesken wrote: > Hi, > > Reading this: > http://netsuperbrain.com/blog/posts/introducing-reactive-events/ > > I stumble upon this: > > type BellMachine = Event () -> Event () Html escaping hiccup (several more of that on the page). It should be type BellMachine = Event () -> Event () so BellMachine is an alias for the type of functions mapping an Event () to an Event (). > > Google did not tell me, what this means. > I understand > > type BellMachine = Event() > > but the rest is completely strange to me. > > What does it mean or where can I find out? > > Thanks! > Nathan ------------------------------ Message: 5 Date: Tue, 8 Jun 2010 13:03:59 -0500 From: aditya siram <aditya.si...@gmail.com> Subject: Re: [Haskell-beginners] Understanding syntax problems To: Daniel Fischer <daniel.is.fisc...@web.de> Cc: beginners@haskell.org Message-ID: <aanlktimqkkro56-ykk940lxnl9zuszgkcrhhclkbg...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 I've been doing way too much HTML - I automatically translated ~> in my head. Ugh. -deech On 6/8/10, Daniel Fischer <daniel.is.fisc...@web.de> wrote: > On Tuesday 08 June 2010 17:14:19, Nathan Huesken wrote: >> Hi, >> >> Reading this: >> http://netsuperbrain.com/blog/posts/introducing-reactive-events/ >> >> I stumble upon this: >> >> type BellMachine = Event () -> Event () > > Html escaping hiccup (several more of that on the page). > > It should be > > type BellMachine = Event () -> Event () > > so BellMachine is an alias for the type of functions mapping an Event () to > an Event (). > >> >> Google did not tell me, what this means. >> I understand >> >> type BellMachine = Event() >> >> but the rest is completely strange to me. >> >> What does it mean or where can I find out? >> >> Thanks! >> Nathan > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners > ------------------------------ Message: 6 Date: Tue, 8 Jun 2010 20:15:20 +0200 From: Daniel Fischer <daniel.is.fisc...@web.de> Subject: Re: [Haskell-beginners] Understanding syntax problems To: beginners@haskell.org Message-ID: <201006082015.20891.daniel.is.fisc...@web.de> Content-Type: text/plain; charset="iso-8859-1" On Tuesday 08 June 2010 19:58:32, Nathan Huesken wrote: > Well, that makes complete sense. > Just out of curiosity, is it my browser or a problem with the site? Not your browser: type</span> BellMachine <span style="color: #339933; font-weight: bold;">=</span> Event <span style="color: green;">(</span><span style="color: green;">)</span> <span style="color: #339933; font- weight: bold;">-</span>&gt; Event <span style="color: green;">(</span><span style="color: green;">) See the &gt; ? > > Regards, > Nathan > > On Tue, 8 Jun 2010 18:52:20 +0100 > > Stephen Tetley <stephen.tet...@gmail.com> wrote: > > Hi > > > > This is a typo - caused in the translation to HTML: > > > > type BellMachine = Event () -> Event () > > > > A Bell Machine is a function from Event to Event. > > > > Representing state machines as functions from their input to their > > output is quite a common pattern in Haskell. > > > > > > Best wishes > > > > Stephen > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners ------------------------------ Message: 7 Date: Wed, 09 Jun 2010 01:23:56 +0200 From: Thomas <hask...@phirho.com> Subject: [Haskell-beginners] profiling weirdness? To: beginners@haskell.org Message-ID: <4c0ed10c.4010...@phirho.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Hello all! Currently this is more of a curiosity for me rather than a real obstacle to learn Haskell, but I'd appreciate any insight into this behaviour nevertheless. Given the (dumb, I know, but it's for illustration purpose) program: --- import Data.Char type Position = (Char, Integer) sameSquare :: Position -> Position -> Bool sameSquare p1 p2 = ssqHelper p1 p2 ssqHelper :: Position -> Position -> Bool ssqHelper (r1, c1) (r2, c2) | (((c1-1) `div` 3) == ((c2-1) `div` 3) && ((((ord r1) - 65) `div` 3) == (((ord r2) - 65) `div` 3))) = True | otherwise = False main :: IO () main = print (sameSquare ('A', 2) ('B', 2)) --- If I compile this with profiling info and run the profiler all seems well (independently of optimization settings). Now, if I comment the line --ssqHelper :: Position -> Position -> Bool and do the same (compile with profiling info) I can see rather surprising results. While I'd expect exactly one call to ssqHelper for every call to sameSquare this is actually only the case if compiled without optimizations. Using -O2 when compiling I get a full 5 calls of ssqHelper for every call to sameSquare. I am unable to imagine an optimization that would be more efficient with five calls instead of one. And I do not understand either what this has to do with the type annotation. Within such a trivial program the inferred type should be equivalent, shouldn't it? Actually ghci generalizes slightly: Integral instead of Integer. But that's no clue for me either... BTW I'm using ghc 6.10.4. (In case it matters.) Any hint would be appreciated. Thanks, Thomas ------------------------------ Message: 8 Date: Wed, 9 Jun 2010 02:41:29 +0200 From: Daniel Fischer <daniel.is.fisc...@web.de> Subject: Re: [Haskell-beginners] profiling weirdness? To: beginners@haskell.org Message-ID: <201006090241.29716.daniel.is.fisc...@web.de> Content-Type: text/plain; charset="iso-8859-1" On Wednesday 09 June 2010 01:23:56, Thomas wrote: > Hello all! > > Currently this is more of a curiosity for me rather than a real obstacle > to learn Haskell, but I'd appreciate any insight into this behaviour > nevertheless. > > Given the (dumb, I know, but it's for illustration purpose) program: > --- > import Data.Char > > type Position = (Char, Integer) > > sameSquare :: Position -> Position -> Bool > sameSquare p1 p2 > = ssqHelper p1 p2 > > ssqHelper :: Position -> Position -> Bool > ssqHelper (r1, c1) (r2, c2) > > | (((c1-1) `div` 3) == ((c2-1) `div` 3) && ((((ord r1) - 65) > > `div` 3) == (((ord r2) - 65) `div` 3))) = True > > | otherwise = False > > main :: IO () > main = print (sameSquare ('A', 2) ('B', 2)) > --- > > If I compile this with profiling info and run the profiler all seems With -auto-all? > well (independently of optimization settings). Now, if I comment the > line --ssqHelper :: Position -> Position -> Bool > and do the same (compile with profiling info) I can see rather > surprising results. While I'd expect exactly one call to ssqHelper for > every call to sameSquare this is actually only the case if compiled > without optimizations. Using -O2 when compiling I get a full 5 calls of > ssqHelper for every call to sameSquare. No, you don't, fortunately. It's an artifact of the code generation. When you compile with optimisations, GHC generates a specialised version of ssqHelper and it inserts several SCC pragmas in that (as well as in the polymorphic version if ssqHelper is exported), while without optimisations it only generates a specialised wrapper and inserts only one SCC pragma in the polymorphic worker. When the code comes across an SCC pragma, that counts as one entry (NB, entries /= calls). So the unoptimised code meets only one pragma per call, hence one entry. The optimised code meets several pragmas (the number depends on the code- path taken) and records several entries per call. > > I am unable to imagine an optimization that would be more efficient with > five calls instead of one. And I do not understand either what this has > to do with the type annotation. Within such a trivial program the > inferred type should be equivalent, shouldn't it? Not quite. No optimisations means GHC generates polymorphic code without the type signature. Only with optimisations does it care that ssqHelper is not exported (I assume you didn't give a module declaration, so it's taken to be "module Main (main) where") and used only at the one type, so produces only the specialised version [or two versions if ssqHelper is exported]. > Actually ghci generalizes slightly: Integral instead of Integer. But > that's no clue for me either... > > BTW I'm using ghc 6.10.4. (In case it matters.) Not much. With 6.12, you get only 3 entries to ssqHelper per sameSquare returning True. > > Any hint would be appreciated. > Thanks, > Thomas > ------------------------------ Message: 9 Date: Tue, 8 Jun 2010 22:13:32 -0400 From: Nathan Huesken <hask...@lonely-star.org> Subject: [Haskell-beginners] Compiling Test.hs from reactive-fieldtrip To: Biginners Haskell Mailinglist <beginners@haskell.org> Message-ID: <20100608221332.7feaa...@samzwo> Content-Type: text/plain; charset=US-ASCII Hi, I am trying to compile the Test.hs form reactive-fieltrip. I did: ghc --make Test (22:09) [1 of 3] Compiling FRP.Reactive.FieldTrip.Adapter ( FRP/Reactive/FieldTrip/Adapter.hs, FRP/Reactive/FieldTrip/Adapter.o ) [2 of 3] Compiling FRP.Reactive.FieldTrip ( FRP/Reactive/FieldTrip.hs, FRP/Reactive/FieldTrip.o ) [3 of 3] Compiling Test ( Test.hs, Test.o ) Wonderfull, only it is not giving me an executable, only Test.o. It has a main function, so how can I compile it? Thanks! nathan ------------------------------ Message: 10 Date: Tue, 8 Jun 2010 21:55:38 -0500 From: aditya siram <aditya.si...@gmail.com> Subject: Re: [Haskell-beginners] Compiling Test.hs from reactive-fieldtrip To: Nathan Huesken <hask...@lonely-star.org> Cc: Biginners Haskell Mailinglist <beginners@haskell.org> Message-ID: <aanlktinhkd4n1lgn5xxe_vsg0d8x2pzpzzdsslpyp...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 To compile an executable, tack on -o <executable_name>, so for instance, ghc --make HelloWorld.hs -o HelloWorld creates an executable called `HelloWorld'. -deech On 6/8/10, Nathan Huesken <hask...@lonely-star.org> wrote: > Hi, > > I am trying to compile the Test.hs form reactive-fieltrip. > I did: > ghc --make > Test > (22:09) [1 of 3] Compiling FRP.Reactive.FieldTrip.Adapter > ( FRP/Reactive/FieldTrip/Adapter.hs, FRP/Reactive/FieldTrip/Adapter.o ) > [2 of 3] Compiling FRP.Reactive.FieldTrip ( FRP/Reactive/FieldTrip.hs, > FRP/Reactive/FieldTrip.o ) [3 of 3] Compiling Test > ( Test.hs, Test.o ) > > Wonderfull, only it is not giving me an executable, only Test.o. > > It has a main function, so how can I compile it? > Thanks! > nathan > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners > ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 24, Issue 8 ****************************************