A brief note on n_k patterns and Hackage

I never really understood why it was thought to be relevant, but I was challenged to show that n+k patterns occurred in Hackage. Last week I downloaded it. I had to miss a couple of days looking after my daughter, but today I got back to it. Guess what? I found one. Having found one I stopped looking. I don't want to start another thread, but having promised that I'd look I thought I should follow that up.

Which package?
/jve
On Mon, May 4, 2009 at 8:04 PM, Richard O'Keefe
I never really understood why it was thought to be relevant, but I was challenged to show that n+k patterns occurred in Hackage.
Last week I downloaded it. I had to miss a couple of days looking after my daughter, but today I got back to it.
Guess what? I found one. Having found one I stopped looking.
I don't want to start another thread, but having promised that I'd look I thought I should follow that up.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

I think the Hinze streams package I uploaded on Sunday uses n+k... http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hinze-streams-1.0 turn :: (Integral a) => a -> [a] turn 0 = [] turn (n + 1) = turn n ++ [n] ++ turn n vanenkj:
Which package?
/jve
On Mon, May 4, 2009 at 8:04 PM, Richard O'Keefe
wrote: I never really understood why it was thought to be relevant, but I was challenged to show that n+k patterns occurred in Hackage.
Last week I downloaded it. I had to miss a couple of days looking after my daughter, but today I got back to it.
Guess what? I found one. Having found one I stopped looking.
I don't want to start another thread, but having promised that I'd look I thought I should follow that up.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

John Van Enk
Which package?
More importantly, is it a recent version, that's still live? Does it compile with ghc > 5.2? -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited.

I presume that is a joke, but it's not very funny.
On Mon, May 4, 2009 at 6:48 PM, Richard O'Keefe
[about n+k in Hackage] On 5 May 2009, at 12:23 pm, John Van Enk wrote:
Which package?
There are at least two occurrences of n+1 as a pattern. If anyone wants to get rid of them, I'd like them to work as hard at this as I did...
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Mon, May 4, 2009 at 5:23 PM, John Van Enk
Which package?
In 1251 packages, I found 20 source files out of 15144 source files that use (n+k) patterns: queuelike-1.0.9/Data/Queue/Stack.hs queuelike-1.0.9/Data/Queue/TrieQueue.hs hinze-streams-1.0/Data/Stream/Hinze/Stream.hs compression-0.1/Codec/Compression/Utils.hs bytestring-0.9.1.4/tests/lazybuildcons.hs bytestring-0.9.1.4/tests/lazybuild.hs liboleg-0.1.1/Language/TypeLC.hs pqueue-mtl-1.0.7/Data/Queue/Stack.hs pqueue-mtl-1.0.7/Data/Queue/Queue.hs IOSpec-0.2/examples/Echo.hs pxsl-tools-1.0.1/src/PxsltFormat.hs pdf2line-0.0.1/pdf2line.hs stream-fusion-0.1.2.1/tests/Test/SmallCheck/Partial.hs queue-0.1.1.3/src/Data/Queue/Instances/STM.hs frag-1.1.2/src/AFRP.hs th-fold-0.0.0.1/src/Language/Haskell/TH/Fold.hs tetris-0.27178/Util.hs random-fu-0.0.0.2/src/Data/Random/Distribution/Binomial.hs random-fu-0.0.0.2/src/Data/Random/Source/PureMT.hs The method that I used to extract them may have missed some files (e.g. anything that is Haskell source but needs to be preprocessed), but I just wanted to save people the trouble of finding them themselves ;) j3h -- For the curious, those who wish to search other sources, or those who wish to improve on my results, I found these by I downloaded the full Hackage tarball, unpacked it and ran: find ./ -type f \( -name \*.hs -o \*.lhs \) | xargs npk where npk is the following program:
import System.Environment ( getArgs ) import Control.Monad ( when ) import Data.Generics ( cast, GenericQ, gcount ) import Language.Haskell.Exts ( Module, ParseResult(..), Pat(..), parseFile )
isNPlusK :: GenericQ Bool isNPlusK x = case cast x of Just (PNPlusK _ _) -> True _ -> False
hasNPlusK :: Module -> Bool hasNPlusK = (> 0) . gcount isNPlusK
printIfNPlusK :: FilePath -> IO () printIfNPlusK fn = do res <- parseFile fn case res of ParseOk mod -> when (hasNPlusK mod) $ putStrLn fn _ -> return ()
main :: IO () main = mapM_ printIfNPlusK =<< getArgs

On Tue, May 5, 2009 at 1:04 AM, Richard O'Keefe
I never really understood why it was thought to be relevant, but I was challenged to show that n+k patterns occurred in Hackage.
Why is it relevant? /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe

On Tue, May 5, 2009 at 1:30 AM, Magnus Therning
On Tue, May 5, 2009 at 1:04 AM, Richard O'Keefe
wrote: I never really understood why it was thought to be relevant, but I was challenged to show that n+k patterns occurred in Hackage.
Why is it relevant?
Showing that they occur was not relevant. Showing the number of occurrences relative to the number of packages, function definitions, and other features was relevant (in my opinion): http://www.mail-archive.com/haskell-cafe@haskell.org/msg58320.html But, I phrased the challenge poorly and this is what we get :) I was just curious if it's a feature worth holding on it (eg., it gets a lot of good use). Sadly, just me commenting here about that goal will probably rekindle the thread we would all like to avoid... My sincerest apologizes if that happens. Jason

On 5 May 2009, at 8:30 pm, Magnus Therning wrote:
On Tue, May 5, 2009 at 1:04 AM, Richard O'Keefe
wrote: I never really understood why it was thought to be relevant, but I was challenged to show that n+k patterns occurred in Hackage.
Why is it relevant?
Some people think that the popularity of a feature in an openly accessible collection of Haskell sources is relevant to whether it should continue to be supported, in a way that, say, appearance in textbooks, utility to beginners, and contribution to readability are not. Apparently. I don't understand this. n+k patterns are the ONLY Haskell98 feature scheduled for removal from Haskell'.

ok:
On 5 May 2009, at 8:30 pm, Magnus Therning wrote:
On Tue, May 5, 2009 at 1:04 AM, Richard O'Keefe
wrote: I never really understood why it was thought to be relevant, but I was challenged to show that n+k patterns occurred in Hackage.
Why is it relevant?
Some people think that the popularity of a feature in an openly accessible collection of Haskell sources is relevant to whether it should continue to be supported, in a way that, say, appearance in textbooks, utility to beginners, and contribution to readability are not. Apparently.
This was the main reason it was kept in Haskell 98, 11 years ago. New textbooks don't use it (RWH doesn't talk or recommend the use of n+k)
I don't understand this. n+k patterns are the ONLY Haskell98 feature scheduled for removal from Haskell'.
For multiple reasons, summarised here: http://hackage.haskell.org/trac/haskell-prime/wiki/RemoveNPlusK -- Don
participants (8)
-
Achim Schneider
-
Don Stewart
-
j3h
-
Jason Dagit
-
John Van Enk
-
Lennart Augustsson
-
Magnus Therning
-
Richard O'Keefe