Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.haskell.org/cgi-bin/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: Basic Trie Implementation: Request for Feedback and QuickCheck Question (Dominik Bollmann) 2. regex and Unicode (Brian Sammon) 3. How do you show a Data.ByteArray? (hask...@verge.info.tm) 4. Re: How do you show a Data.ByteArray? (David McBride) 5. Re: How do you show a Data.ByteArray? (hask...@verge.info.tm) ---------------------------------------------------------------------- Message: 1 Date: Sun, 28 Aug 2016 14:26:40 +0200 From: Dominik Bollmann <dominikbollm...@gmail.com> To: beginners@haskell.org Subject: Re: [Haskell-beginners] Basic Trie Implementation: Request for Feedback and QuickCheck Question Message-ID: <87k2f1w03j.fsf@t450s.i-did-not-set--mail-host-address--so-tickle-me> Content-Type: text/plain Just a short update, in case anyone reads along. I found the the problem with question (2) from the previous mail: My Arbitrary instance for TrieS was simply wrong and sometimes looped forever, which caused the program to hang. Besides I found another bug (prefixes of words were always found as well) which I've fixed now. The updated code is here: http://lpaste.net/180994 Anyhow, if anyone has any suggestions on how to improve the code style-wise, etc., I would be very happy to hear them! Cheers, Dominik. Dominik Bollmann <dominikbollm...@gmail.com> writes: > Hello Haskellers, > > I just finished implementing a very simple Trie module, consisting of a > Trie data type as well as operations `insert` and `lookup`. Function > `insert` inserts a new element into the Trie; function lookup searches > for all words in the Trie that match a specific pattern. Besides regular > words, a pattern may consist of a single dot '.', indicating that at > this position of the search term any letter may occur. For example a > pattern "hello" would just search for the word "hello" in the Trie, > while ".ello" would search words starting in *any* letter and followed > by the sequence "ello" (i.e., it searches for "hello", "Hello", "Aello", > etc.) > > The code for the Trie module can be found here: http://lpaste.net/180768. > > Regarding the code I have two questions: > > (1) Since I'm new to Haskell, I'd very much welcome feedback on the > general implementation of the Trie module and its two methods what > I could improve. > > (2) While testing the Trie module with QuickCheck, I wrote the > property `prop_insert_then_lookup_succeeds` stating that after > inserting a word into a Trie it can always successfully be looked > up again. While quickchecking this property seems to succeed, I > cannot verbose check it. In particular, when I run > > `verboseCheck prop_insert_then_lookup_succeeds` > > this property consumes all my main memory and results in the > program hanging. > > Does anyone know what I messed up in devising the quickcheck > property? I guess I left open some memory leak... Maybe it has to > to with the Arbitrary instance which I might have defined > incorrectly? > > Responses to any of the two questions above are very welcome :-) > > Thanks! > > Dominik. ------------------------------ Message: 2 Date: Sun, 28 Aug 2016 15:11:24 -0400 From: Brian Sammon <haskell-beginn...@brisammon.fastmail.fm> To: beginners@haskell.org Subject: [Haskell-beginners] regex and Unicode Message-ID: <20160828151124.9b07004e2450bc25ae966...@brisammon.fastmail.fm> Content-Type: text/plain; charset=US-ASCII I tried to write a program using Text.Regex.PCRE to search through a UTF8-encoded document. It appears that the presence of non-breaking-space characters (Charpoint 160) triggers some weird behavior in my program. This is using the Debian stable(Jessie) packages of ghc 7.6.3 and libraries. Now I find myself at a fork in the road, not sure which direction to head in. Do I: 1) Continue looking (or get help with looking) for bugs in my code? (I have this reduced to a pretty small test case) 2) Assemble a bug-report against debian? 3) Assemble a bug-report against Text.Regex.PCRE (or Text.Regex.Base) for "upstream" 4) Uninstall Text.Regex.PCRE (and/or some other packages) and switch to something that works with Unicode/UTF8? Any ideas? ------------------------------ Message: 3 Date: Sun, 28 Aug 2016 22:56:29 +0000 From: hask...@verge.info.tm To: beginners@haskell.org Subject: [Haskell-beginners] How do you show a Data.ByteArray? Message-ID: <2778780b-5c51-bf1b-f9bb-ee2c5a979...@verge.info.tm> Content-Type: text/plain; charset=utf-8 Prelude Data.ByteArray> c = Data.ByteArray.zero 20 Prelude Data.ByteArray> :type c c :: ByteArray ba => ba Prelude Data.ByteArray> c <interactive>:38:1: error: • Ambiguous type variable ‘a0’ arising from a use of ‘print’ Uhm... Prelude Data.ByteArray> index c 3 <interactive>:39:1: error: • Ambiguous type variable ‘a0’ arising from a use of ‘index’ I can't print a byte? ------------------------------ Message: 4 Date: Sun, 28 Aug 2016 19:08:19 -0400 From: David McBride <toa...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] How do you show a Data.ByteArray? Message-ID: <CAN+Tr4186Gy8rsJB4rsBzAMZyVrpC5RHY3QeifA=9xu122f...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" You haven't actually decided what c is, just that it is some type that is an instance of the ByteArray class. :i ByteArray should show: instance ByteArray ByteString instance ByteArray Bytes instance ByteArray ScrubbedBytes try print (c :: ByteString) print (c :: ScrubbedBytes) On Sun, Aug 28, 2016 at 6:56 PM, <hask...@verge.info.tm> wrote: > Prelude Data.ByteArray> c = Data.ByteArray.zero 20 > Prelude Data.ByteArray> :type c > c :: ByteArray ba => ba > Prelude Data.ByteArray> c > > <interactive>:38:1: error: > • Ambiguous type variable ‘a0’ arising from a use of ‘print’ > > Uhm... > > Prelude Data.ByteArray> index c 3 > > <interactive>:39:1: error: > • Ambiguous type variable ‘a0’ arising from a use of ‘index’ > > I can't print a byte? > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160828/03e8955f/attachment-0001.html> ------------------------------ Message: 5 Date: Mon, 29 Aug 2016 02:17:35 +0000 From: hask...@verge.info.tm To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] How do you show a Data.ByteArray? Message-ID: <661d461d-a8ea-6d71-1514-bfc62160a...@verge.info.tm> Content-Type: text/plain; charset=utf-8 On 08/28/2016 11:08 PM, David McBride wrote: > You haven't actually decided what c is, just that it is some type that is an > instance of the ByteArray class. Thank you! I had thought there was a default instance, like it would by default be Bytes, but could also optionally be wrapped around a ByteString or ScrubbedBytes. But you're right, you can create "20 zeroes" of any of those underlying things. Makes a lot more sense now. ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 98, Issue 22 *****************************************