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: Haskore lib (Stephen Tetley) 2. Re: Haskore lib (Luca Ciciriello) 3. Re: Haskore lib (Stephen Tetley) 4. Re: Haskore lib (aditya siram) 5. Testing a data structure, etc (matthew coolbeth) 6. Re: Testing a data structure, etc (Stephen Tetley) 7. Re: Haskore lib (Luca Ciciriello) 8. Re: Testing a data structure, etc (Felipe Lessa) ---------------------------------------------------------------------- Message: 1 Date: Sat, 19 Jun 2010 09:24:20 +0100 From: Stephen Tetley <stephen.tet...@gmail.com> Subject: Re: [Haskell-beginners] Haskore lib To: Luca Ciciriello <luca_cicirie...@hotmail.com> Cc: beginners@haskell.org Message-ID: <aanlktimbxafrt3gvsy8oq5matnj-u_4qyo5sscvlp...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Hi Luca (:+:) is sequential composition - think a melody. (:=:) is parallel composition - think chords. You might find the package - haskore-vintage on Hackage - easier to start with than Henning Thielemann's revised Haskore. Haskore-vintage matches Paul Hudak's original Haskore, which is described in a substantial tutorial. The full Haskore tutorial used to be available from Paul Hudak's home page a Yale - but now that page now seems "under re-construction", a copy is available here: http://www.cs.lth.se/EDA120/assignment2/tutorial.pdf Or PS if you have GhostScript: http://haskell.org/haskore/Haskore/Haskore/Docs/tutorial.ps Or html (though seemingly an older version): http://www.haskell.org/haskore/onlinetutorial/index.html Best wishes Stephen ------------------------------ Message: 2 Date: Sat, 19 Jun 2010 13:39:10 +0200 From: Luca Ciciriello <luca_cicirie...@hotmail.com> Subject: Re: [Haskell-beginners] Haskore lib To: Stephen Tetley <stephen.tet...@gmail.com> Cc: beginners@haskell.org Message-ID: <blu0-smtp2066bca31487d2a50b7f7b9a...@phx.gbl> Content-Type: text/plain; charset=us-ascii Thanks Stephen. Can I install this Haskore-Vintage along side with my installed Haskore? Luca. On Jun 19, 2010, at 10:24 AM, Stephen Tetley wrote: > Hi Luca > > (:+:) is sequential composition - think a melody. > (:=:) is parallel composition - think chords. > > You might find the package - haskore-vintage on Hackage - easier to > start with than Henning Thielemann's revised Haskore. Haskore-vintage > matches Paul Hudak's original Haskore, which is described in a > substantial tutorial. The full Haskore tutorial used to be available > from Paul Hudak's home page a Yale - but now that page now seems > "under re-construction", a copy is available here: > > http://www.cs.lth.se/EDA120/assignment2/tutorial.pdf > > Or PS if you have GhostScript: > http://haskell.org/haskore/Haskore/Haskore/Docs/tutorial.ps > > Or html (though seemingly an older version): > http://www.haskell.org/haskore/onlinetutorial/index.html > > Best wishes > > Stephen > ------------------------------ Message: 3 Date: Sat, 19 Jun 2010 12:57:17 +0100 From: Stephen Tetley <stephen.tet...@gmail.com> Subject: Re: [Haskell-beginners] Haskore lib To: Luca Ciciriello <luca_cicirie...@hotmail.com> Cc: beginners@haskell.org Message-ID: <aanlktimhchawfs17tdi8zkjpurzmxcjmic_r9q1lz...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 On 19 June 2010 12:39, Luca Ciciriello <luca_cicirie...@hotmail.com> wrote: > Can I install this Haskore-Vintage along side with my installed Haskore? > Yes. Though there is a module name-space clash for Haskore.Performance at least. One way around the name-space clash is PackageImports: http://hackage.haskell.org/trac/ghc/wiki/PackageImports Or I think you can invoke GHCi telling it which one to use: > ghci -package haskore-vintage ------------------------------ Message: 4 Date: Sat, 19 Jun 2010 08:55:45 -0400 From: aditya siram <aditya.si...@gmail.com> Subject: Re: [Haskell-beginners] Haskore lib To: Luca Ciciriello <luca_cicirie...@hotmail.com> Cc: beginners@haskell.org Message-ID: <aanlktikdaa5x6dj4pv5ac2qmr3ea7pp80c2flqbgx...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Hi Luca, I wrote some code [1] for a little Haskell music hackfest last November. It uses Haskore to control a Supercollider audio server [2]. The code is completely uncommented and, in parts, quite hackish, but if you have questions I am happy to help. -deech [1] https://patch-tag.com/r/deech2k/SuperCollider-Haskell/snapshot/current/content/pretty/HaskoreHackfest.hs [2] http://supercollider.sourceforge.net// On Sat, Jun 19, 2010 at 7:39 AM, Luca Ciciriello <luca_cicirie...@hotmail.com> wrote: > Thanks Stephen. > > Can I install this Haskore-Vintage along side with my installed Haskore? > > Luca. > > On Jun 19, 2010, at 10:24 AM, Stephen Tetley wrote: > >> Hi Luca >> >> (:+:) is sequential composition - think a melody. >> (:=:) is parallel composition - think chords. >> >> You might find the package - haskore-vintage on Hackage - easier to >> start with than Henning Thielemann's revised Haskore. Haskore-vintage >> matches Paul Hudak's original Haskore, which is described in a >> substantial tutorial. The full Haskore tutorial used to be available >> from Paul Hudak's home page a Yale - but now that page now seems >> "under re-construction", a copy is available here: >> >> http://www.cs.lth.se/EDA120/assignment2/tutorial.pdf >> >> Or PS if you have GhostScript: >> http://haskell.org/haskore/Haskore/Haskore/Docs/tutorial.ps >> >> Or html (though seemingly an older version): >> http://www.haskell.org/haskore/onlinetutorial/index.html >> >> Best wishes >> >> Stephen >> > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners > ------------------------------ Message: 5 Date: Sat, 19 Jun 2010 09:17:02 -0400 From: matthew coolbeth <mac01...@engr.uconn.edu> Subject: [Haskell-beginners] Testing a data structure, etc To: Haskell-beginners <beginners@haskell.org> Message-ID: <aanlktinnnkqft9eq3lnz1zkejocxbtpyeplifipf_...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" As an excercise, I have created a small module defining a data structure which is intended to be an efficient map from sequences (possibly very long ones) to objects of some other type. The source code is below for anyone interested. Three questions. Hopefully they aren't too naive: 1) Can anyone point me toward whatever standard modules would be most appropriate for timing this (or measuring other kinds of performance) against the naive Data.Map? 2) Any suggestions on how to improve the module itself are more than welcome. 3) In a language like this with meaningful white-space, how do people keep their lines of source code from getting too wide? There is one line below that stretched beyond the desired 80 characters and, in general, I seem to have a hard time avoiding this. Thanks for your help. -- mac -- A map from [a] to p module SequenceMap (SequenceMap, empty, insert, lookup, test) where import Prelude hiding (lookup) import qualified Data.Map import Data.Maybe data Ord a => SequenceMap a p = SequenceMap (Maybe p) (Data.Map.Map a (SequenceMap a p)) empty :: Ord a => SequenceMap a p empty = SequenceMap Nothing Data.Map.empty lookup :: Ord a => [a] -> SequenceMap a p -> Maybe p lookup [] (SequenceMap p m) = p lookup (a:as) (SequenceMap p m) = let msm = Data.Map.lookup a m in case msm of Nothing -> Nothing Just sm -> lookup as sm insert :: Ord a => [a] -> p -> SequenceMap a p -> SequenceMap a p insert [] p (SequenceMap oldP othrs) = SequenceMap (Just p) othrs insert (a:as) p (SequenceMap notP othrs) = let msm = Data.Map.lookup a othrs in case msm of Nothing -> SequenceMap notP (Data.Map.insert a (insert as p empty) Data.Map.empty) Just sm -> SequenceMap notP (Data.Map.insert a (insert as p sm) othrs) test :: Bool test = fromMaybe False (lookup "qwerty" (insert "qwerty" True empty)) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20100619/048f1757/attachment-0001.html ------------------------------ Message: 6 Date: Sat, 19 Jun 2010 15:43:32 +0100 From: Stephen Tetley <stephen.tet...@gmail.com> Subject: Re: [Haskell-beginners] Testing a data structure, etc Cc: Haskell-beginners <beginners@haskell.org> Message-ID: <aanlktimukmcn7oesct8gntntus8u8mrerfmsf8sd9...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Hi Matthew A quick one to reduce line width is to import qualified with a single character alias: import qualified Data.Map as M Then the longest line becomes: Nothing -> SequenceMap notP (M.insert a (insert as p empty) M.empty) ... saving 2x7 characters in this case. As for performance always compile (never use GHCi) and always use -O2 otherwise rewrite-rules and other optimizations will not be used by GHC. When you run the executable, get the runtime system to print its stats: ./MyProg +RTS -sstderr -RTS ... This will print memory usage, garbage collection and timing stats. For serious work there is also the Criterion bench-marking package. Best wishes Stephen ------------------------------ Message: 7 Date: Sat, 19 Jun 2010 16:44:39 +0200 From: Luca Ciciriello <luca_cicirie...@hotmail.com> Subject: Re: [Haskell-beginners] Haskore lib To: aditya siram <aditya.si...@gmail.com> Cc: beginners@haskell.org Message-ID: <blu0-smtp900081cd97c5da1d389699a...@phx.gbl> Content-Type: text/plain; charset=us-ascii Thanks, this is useful. Luca. On Jun 19, 2010, at 2:55 PM, aditya siram wrote: > Hi Luca, > I wrote some code [1] for a little Haskell music hackfest last > November. It uses Haskore to control a Supercollider audio server [2]. > > The code is completely uncommented and, in parts, quite hackish, but > if you have questions I am happy to help. > > -deech > > [1] > https://patch-tag.com/r/deech2k/SuperCollider-Haskell/snapshot/current/content/pretty/HaskoreHackfest.hs > [2] http://supercollider.sourceforge.net// > > On Sat, Jun 19, 2010 at 7:39 AM, Luca Ciciriello > <luca_cicirie...@hotmail.com> wrote: >> Thanks Stephen. >> >> Can I install this Haskore-Vintage along side with my installed Haskore? >> >> Luca. >> >> On Jun 19, 2010, at 10:24 AM, Stephen Tetley wrote: >> >>> Hi Luca >>> >>> (:+:) is sequential composition - think a melody. >>> (:=:) is parallel composition - think chords. >>> >>> You might find the package - haskore-vintage on Hackage - easier to >>> start with than Henning Thielemann's revised Haskore. Haskore-vintage >>> matches Paul Hudak's original Haskore, which is described in a >>> substantial tutorial. The full Haskore tutorial used to be available >>> from Paul Hudak's home page a Yale - but now that page now seems >>> "under re-construction", a copy is available here: >>> >>> http://www.cs.lth.se/EDA120/assignment2/tutorial.pdf >>> >>> Or PS if you have GhostScript: >>> http://haskell.org/haskore/Haskore/Haskore/Docs/tutorial.ps >>> >>> Or html (though seemingly an older version): >>> http://www.haskell.org/haskore/onlinetutorial/index.html >>> >>> Best wishes >>> >>> Stephen >>> >> >> _______________________________________________ >> Beginners mailing list >> Beginners@haskell.org >> http://www.haskell.org/mailman/listinfo/beginners >> > ------------------------------ Message: 8 Date: Sat, 19 Jun 2010 12:13:00 -0300 From: Felipe Lessa <felipe.le...@gmail.com> Subject: Re: [Haskell-beginners] Testing a data structure, etc To: matthew coolbeth <mac01...@engr.uconn.edu> Cc: Haskell-beginners <beginners@haskell.org> Message-ID: <20100619151259.ga5...@kira.casa> Content-Type: text/plain; charset=us-ascii On Sat, Jun 19, 2010 at 09:17:02AM -0400, matthew coolbeth wrote: > 2) Any suggestions on how to improve the module itself are more than > welcome. You seem to be implementing a Trie. There are many Trie-implementing packages on Hackage, such as: http://hackage.haskell.org/package/TrieMap http://hackage.haskell.org/package/bytestring-trie http://hackage.haskell.org/package/data-inttrie http://hackage.haskell.org/package/list-tries http://hackage.haskell.org/package/gmap Probably you could use one of those. In particular, Patricia tries should be useful for you if you have few long sequences. Cheers, -- Felipe. ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 24, Issue 22 *****************************************