Re: [Haskell-cafe] Display an inferred type during compilation

2013-04-27 Thread Gwern Branwen
On Sat, Apr 27, 2013 at 12:55 PM, Corentin Dupont
 wrote:
> can I ask the compiler to display the type of an inferred value during
> compile time?
> It would be great if I can output a string during compilation with the type.
> A little bit like running :type in GHCi, but without GHCi... Because running
> GHCi is sometime painful (I have to clean my code first).

You could try floating a value to the top level; then I believe -Wall
will make ghc print out the inferred type since you didn't give a type
signature.

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Resource Limits for Haskell

2013-04-04 Thread Gwern Branwen
On Mon, Apr 1, 2013 at 5:56 PM, Edward Z. Yang  wrote:

>  http://ezyang.com/papers/ezyang13-rlimits.pdf
>


Correct me if I'm wrong, but reading that I don't seem to see any tests
against actual adversarial code - just checking that the limits kick in on
a bunch of ordinary code.

-- 
gwern
http://www.gwern.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] mueval, interpreter options

2013-04-02 Thread Gwern Branwen
On Tue, Apr 2, 2013 at 1:34 PM, Johannes Waldmann <
waldm...@imn.htwk-leipzig.de> wrote:

> I don't understand mueval's design anyway here:
> do the interpreter options mean that these are automatically on,
> or just that the source text will be allowed to switch then on?
> (I'd prefer the latter.)
>

I'm not clear on what you're doing there (I don't recognize your snippet),
but extensions are enabled as options:

  -X EXTENSION   --extension=EXTENSIONPass additional flags enabling
extensions just like you would to ghc. Example: -XViewPatterns

So for example:

$ mueval -e "let f (id -> x) = x in f 1" -XViewPatterns
 1
$ mueval -e "let f (id -> x) = x in f 1" -XMultiParamTypeClasses
 Illegal view pattern:  id -> x
 Use -XViewPatterns to enable view patterns

-- 
gwern
http://www.gwern.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Specialized Computer Architecture - A Question

2013-03-18 Thread Gwern Branwen
On Mon, Mar 18, 2013 at 4:31 PM, OWP  wrote:
> If I may ask, I'm not quite sure what O(2^n) and O(1) are?

Just a metaphor using algorithmic complexity, is all.

> I'm curious, were not all these built on the foundation of Moore's
> Law?  Everything Vigoda lists has Moore's Law in mind.  If Moore's Law
> were to suddenly disappear, could these survive on their own merit?

No one really knows, since Moore's law has operated for so long. There
seem to be constant factors to be had in my opinion* but in some
problems/areas/domains, ASICs don't seem to help very much**, and we
should not forget the colossal investments that a cutting-edge X86
chip fab represents*** which may make the best general bang for buck a
commodity processor. For example, for every person who trumpets a 100x
gain in switching their program to a GPU, there's another person
abandoning their effort because they lose all the speed gains in
transferring data back and forth from the GPU.

But I think this is getting pretty off-topic for Haskell-cafe.

* I'm not an expert, but some useful material is in
http://www.gwern.net/Aria%27s%20past,%20present,%20and%20future#fn3
and http://www.gwern.net/Self-decrypting%20files#constant-factors
** the more serial a problem is, the more conditionals, memory
accesses, and distinct operations a task requires, the more the
optimal processor will... look like a CPU.
*** http://www.gwern.net/Slowing%20Moore%27s%20Law#fab-costs-and-requirements

-- 
gwern

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Specialized Computer Architecture - A Question

2013-03-17 Thread Gwern Branwen
On Sun, Mar 17, 2013 at 5:56 PM, OWP  wrote:
> These "stock architectures", were they really so good that they out
> performed the specialized ones on it's own merits or was this mainly due to
> Moore's Law on transistors?  In other words, suppose we separate Moore's Law
> from the stock architecture, would it still outperform the specialized ones?

It's not really meaningful to separate them. Any time you use a custom
architecture, you are forfeiting all sorts of network effects - and
sooner or later, the custom architecture falls behind. If you want to
make an analogy, when you go with a custom architecture, you are
trading a process where your computing power increases O(2^n) for one
with a big constant factor but where computing power increases O(1)...

> "In practice replacing digital computers with an alternative computing 
> paradigm is a risky proposition.
Alternative computing architectures, such as parallel digital
computers have not tended to be commercially viable, because Moore's
Law has consistently enabled conventional von Neumann architectures to
render alternatives unnecessary. Besides Moore's Law, digital
computing also benefits from mature tools and expertise for optimizing
performance at all levels of the system: process technology,
fundamental circuits, layout and algorithms. Many engineers are
simultaneously working to improve every aspect of digital technology,
while alternative technologies like analog computing do not have the
same kind of industry juggernaut pushing them forward."

from Benjamin Vigoda, "Analog Logic: Continuous-Time Analog Circuits
for Statistical Signal Processing" (2003 PhD thesis)

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Resource Limits for Haskell

2013-03-15 Thread Gwern Branwen
On Fri, Mar 15, 2013 at 5:17 PM, Edward Z. Yang  wrote:
> There is a lot of subtlety in this space, largely derived from the
> complexity of interpreting GHC's current profiling information.  Your
> questions, comments and suggestions are greatly appreciated!

How secure is this? One of the reasons for forking a process and then
killing it after a timeout in lambdabot/mueval is because a thread can
apparently block the GC from running with a tight enough loop and the
normal in-GHC method of killing threads doesn't work. Can one
simultaneously in a thread allocate ever more memory and suppress kill
signals?

--
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Maintaining lambdabot

2013-02-20 Thread Gwern Branwen
On Wed, Feb 20, 2013 at 1:35 PM, Jan Stolarek  wrote:
> Gwern, and what do you think about James' fork of lambdabot? It seems that 
> there was a lot of work
> put into it and that this is indeed a good starting point to continue 
> development.

I haven't looked at the diffs; if as he says the security around the
evaluation has been weakened, that's a deal-breaker until it's fixed.
lambdabot can't be insecure since it will be run in a public IRC.

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Maintaining lambdabot

2013-02-20 Thread Gwern Branwen
On Wed, Feb 20, 2013 at 12:59 PM, Jan Stolarek  wrote:
> Exactly. This allows to use and develop these packages independently of 
> lambdabot and I consider
> that a Good Thing. I'm also much in favor of using git, because github allows 
> easy collaboration
> between community members.

It may be a good thing, but speaking as the de facto maintainer of
lambdabot for the past few years, it's a very small good thing and the
goodness may be outweighed by the costs of switching: hardly anyone
ever sends in patches for lambdabot proper, and even fewer for those
add-on runtime dependencies.

I am reminded of a recent incident on the XMonad mailing list: an
enthusiastic young member proposed changing the entire infrastructure
to Github because Github is the new hotness and it would surely
promote easy collaboration between community members and so on and so
forth. He put in a bunch of work in making copies and converting repos
etc, and... nothing happened. His effort was wasted. Turns out the
reason for people not submitting patches had more to do with things
besides not being hosted on Github.

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Maintaining lambdabot

2013-02-19 Thread Gwern Branwen
On Tue, Feb 19, 2013 at 5:36 PM, Jan Stolarek  wrote:
> - remove unlambda, brainfuck and show from the repo. They are on hackage, no 
> need to keep them
> here - these packages aren't even used in the build process.

Where will they go?

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] A list of Haskell-related quotes?

2013-02-06 Thread Gwern Branwen
On Wed, Feb 6, 2013 at 5:36 PM, Petr Pudlák  wrote:
> Does anybody collect them or know about such a collection?

You can look at the Haskell Weekly News quote sections, or you can
download the lambdabot source repo and read the State/quote file.

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Substantial (1:10??) system dependencies of runtime performance??

2013-02-02 Thread Gwern Branwen
On Sat, Feb 2, 2013 at 3:19 PM, Nick Rudnick  wrote:
> Roughly, I would say the differences in runtime can reach a factor as much
> as 1:10 at many times -- and so I am curious whether this subject has
> already been observed or even better discussed elsewhere. I have spoken to
> somebody, and our only plausible conclusion was that software like web
> browsers is able to somewhat aggressively claim system resources higher in
> the privilege hierarchy (cache?? register??), so that they are not available
> to other programs any more.

Maybe the Haskell program requires a lot of disk IO? That could easily
lead to a big performance change since disk is so slow compared to
everything else these days. You could try looking with 'lsof' to see
if the browser has a ton of files open or try running the Haskell
program with higher or lower disk IO priority via 'ionice'.

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Most used functions in hackage

2013-02-01 Thread Gwern Branwen
One thing you could do is download Hackage (easy enough with a little
scripting of 'cabal list'; see for example
http://www.haskell.org/pipermail/haskell-cafe/2011-July/093669.html ),
unpack, and use Language.Haskell.Exts to parse every Haskell file.
Here are two examples from the past:

1. http://www.haskell.org/pipermail/haskell-cafe/2012-January/098618.html
function-name search script which lets you parse a large number of
source files and print out anything calling a specified function (eg.
if you were thinking about deprecating something)
2. http://www.haskell.org/pipermail/haskell-cafe/2011-May/091663.html
language-extension search script; I used it to see how many source
files ever invoked LANGUAGE pragmas and which ones.

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Haskell Summers of Code retrospective (updated for 2012)

2013-01-01 Thread Gwern Branwen
The Wheel turns, and months come and pass, leaving web links that fade
into 403 Forbiddens; a wind rose in NYC, whispering of the coming
Winter...

As is now customary for me, I've looked into how the 2012 SoCs went -
the better to feed my misanthropic heart by mocking the students who
failed my whimsically arbitrary and subjective standards:
http://www.gwern.net/Haskell%20Summer%20of%20Code#results-2

This was not a good year. 2 students simply dropped out period, and 3
other projects turned out badly, leaving just 2 clearly successful
projects for the year. Hopefully 2013 will turn out better.

/r/haskell: 
http://www.reddit.com/r/haskell/comments/15sjur/summer_of_code_2012_retrospective/

-- 
gwern

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] delete http://www.haskell.org/haskellwiki/Haskell_IDE

2012-11-28 Thread Gwern Branwen
On Wed, Nov 28, 2012 at 3:24 PM, Roman Beslik  wrote:
> A humble link "What links here" to the right will help you find those pages.

Only for wikipages, nowhere else on the Internet.

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] size of Haskell Platform

2012-11-11 Thread Gwern Branwen
On Sun, Nov 11, 2012 at 11:59 AM, Doug McIlroy  wrote:
> So it seems to be with Haskell Platform, which aims to include
> "all you need to get up and running"--"an extensive set of
> standard libraries and utilities with full documentation." I
> get the impression that the Platform is bedeviled by the
> same prospect of almost unfettered growth.

That's an interesting story, but I think the analogy is fundamentally broken.

So the pump needed someone to watch it, needed spares, needed multiple
people for multiple shifts, then they needed mechanics and motor pools
and all their families came along etc until finally it was a little
town? Well, OK.

But there's no such effect in software libraries - if I add in a
bytestring library to the HP, I don't wind up needing a MS Excel shim
library to service it! When I added in some popular core library like
bytestring, there's no expansionary loop - I don't find myself needing
to add in a dozen libraries just to make bytestring run better.
Bytestring already runs fine. Its dependencies are all already in the
HP; the additional complexity for adding Bytestring is just...
Bytestring. The arrow of dependency points the other way than in your
story - if I need a MS Excel shim library, maybe I'll need the
bytestring library. It's a pyramid, not a repeatedly cycling positive
feedback loop.

(Incidentally, Geoffrey West's city research suggests that cities
benefit from sublinear scaling of most infrastructure; so "barely
missing criticality" is not at all surprising.)

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] [Off-topic] How unimportant it is whether submarines can swim (EWD1056)

2012-10-26 Thread Gwern Branwen
On Fri, Oct 26, 2012 at 4:51 PM, Henk-Jan van Tuyl  wrote:
>
> L.S.,
>
> I thought you might be interested to know, that I have translated one of
> prof. Edsger W. Dijkstra's writings to English[0]. I will submit this
> translation to the E. W. Dijkstra Archive of the University of Texas[1].

Comments:

- "with which popular believe" (popular belief?)
- "between day and night" (night and day is more idiomatic in English,
isn't it?)
- 'The advantage of this poetic license is that it allows us to put an
algebraic expression as (a+b)/c, a program fragment as x := x+1, and a
decimal number like 729 all three under the same heading "formula".'
(all three is weirdly run together with the list)
- "Our traditional argues" (?)

The hyphenation also strikes me as odd but I guess not actually wrong.

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hackage Package Discoverability

2012-10-23 Thread Gwern Branwen
On Tue, Oct 23, 2012 at 1:53 AM, Myles C. Maxfield
 wrote:
> Is there a better way to make this algorithm discoverable?

How about deprecation pragmas?
http://www.haskell.org/ghc/docs/7.2.2/html/users_guide/pragmas.html

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Getting PID of a child process

2012-10-18 Thread Gwern Branwen
On Thu, Oct 18, 2012 at 5:03 PM, Jason Dusek  wrote:
> For diagnostic purposes, I'd like to print the PID of the
> process attached to this handle -- how best to do that?

In Mueval when I wanted the PID (so I could later send sigkills), I did this:

  hdl <- runProcess "mueval-core" args Nothing Nothing Nothing
Nothing Nothing
  _ <- forkIO $ do
 threadDelay (7 * 70)
 status <- getProcessExitCode hdl
 case status of
 Nothing -> do terminateProcess hdl
   _ <- withProcessHandle hdl (\x
-> case x of

OpenHandle pid -> signalProcess 9 pid >> return (undefined, undefined)

_ -> return (undefined,undefined))
   exitWith (ExitFailure 1)
 Just a -> exitWith a
  stat <- waitForProcess hdl
  exitWith stat

The key is the poorly documented withProcessHandle ::
System.Process.Internals.ProcessHandle -> (ProcessHandle__ -> IO
(ProcessHandle__, a)) -> IO a

The implementation:

data ProcessHandle__ = OpenHandle PHANDLE | ClosedHandle ExitCode
type PHANDLE = CPid

Well, my code seems to work, anyway...

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to take a minimum sub list that only contain certain number of elements of certain type?

2012-09-25 Thread Gwern Branwen
On Tue, Sep 25, 2012 at 8:45 PM, Richard O'Keefe  wrote:
> That doesn't work either.  Consider the list [1,1,1,1,1].
> The element just after the 5th odd number in the list is 1;
> takeWhile (/= 1) will thus return [] instead of [1,1,1,1].

I'm not sure that OP would prefer [1,1,1,1] to []. Another area of
underspecification.

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to take a minimum sub list that only contain certain number of elements of certain type?

2012-09-25 Thread Gwern Branwen
On Tue, Sep 25, 2012 at 8:17 PM, Richard O'Keefe  wrote:
> Wrong.  The original poster gave an explicit example
> in which even elements were *retained* in the output,
> they just weren't *counted*.

You are at least the fourth person to email me now to point this out.
I'm glad I could make four people's day better with the joy of
correction...

But I never said it was a full solution - please note that I did
include the output of the function!

One could consider it a partial solution, however: that gives you the
_nth_ odd, so if you want a list of numbers up to the _nth_ odd, that
gives you a stop condition - 'takeWhile =/ nth+1' etc. A 2N traverse
(which laziness might fuse to just 1 traverse, dunno).

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to take a minimum sub list that only contain certain number of elements of certain type?

2012-09-25 Thread Gwern Branwen
On Tue, Sep 25, 2012 at 1:42 PM, Rishabh Jain  wrote:
> f x 0 = []
> f (x:xs) y | x `mod` 2 == 0 = x : (f xs y) | otherwise = x : (f xs (y-1))
>
>> f [0..] 4
>> [0,1,2,3,4,5,6,7]

Tsk, tsk. So ugly. How's this:

> let f x = take x . filter odd
>
> f 4 [0..]
~> [1, 3, 5, 7]

Notice that 0 is excluded, since 0 is *even*, not odd:
http://en.wikipedia.org/wiki/Parity_of_zero
If this is a serious problem, one can always just prepend zero:

> 0 : f 4 [1..]
~> [0, 1, 3, 5, 7]

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Darcs fetches too little files

2012-08-24 Thread Gwern Branwen
On Fri, Aug 24, 2012 at 4:47 PM, Henk-Jan van Tuyl  wrote:
> I am trying to fetch wxHaskell with the command
>   darcs get --lazy http://code.haskell.org/wxhaskell/
> but there are much too little files downloaded; what could be the problem?
>
> I'm working on Windows XP, both in an MS-DOS shell and an MSYS shell.
> Installed Darcs version: 2.8.1

Could you be more specific? The point of --lazy *is* to fetch very few
files, so as described, it's working as it should...

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] [Haskell] Spam on the Haskell wiki

2012-08-04 Thread Gwern Branwen
On Fri, Aug 3, 2012 at 10:34 PM, damodar kulkarni
 wrote:
> So, another doubt, if detecting spam is trivial, then why not just send the
> detected spam to trash directly without any human inspection?
> This may mean some trouble for the posters due to "false positives"; but the
> moderator's job can be reduced to some extent.

Which is pretty much what this whole thread is about: asking that the
sysadmins Do Something about this trivial yet overwhelming spam.

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] [Haskell] Spam on the Haskell wiki

2012-08-03 Thread Gwern Branwen
On Mon, Jul 30, 2012 at 6:59 PM, Alexander Solla  wrote:
> We could even have a "report spam" button on each page, and if enough users
> click on it (for a given revision), the revision gets forwarded to a
> moderator.

This would be useless. The problem is not detecting spam, since that's
quite trivial: it's very hard to miss. The problem is that the
moderator (ie. me) is already overworked. The spam needs to be reduced
to begin with, not detected.

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] lambdabot-4.2.3.3

2012-07-18 Thread Gwern Branwen
On Wed, Jul 18, 2012 at 11:12 AM, James Cook  wrote:
>  It diverged from the official version quite a while ago, but it builds on 
> the latest GHC and uses Safe Haskell for the @eval module.

That doesn't sound very safe. How does it handle all the DoS attacks
etc in the mueval test suite?

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Finding longest common prefixes in a list

2012-01-23 Thread Gwern Branwen
On Sat, Jan 21, 2012 at 8:18 AM, Twan van Laarhoven  wrote:
> Notice that there are lots of "miku-X" prefixes found. This is probably not
> what you want. What exactly do you want the algorithm to do? For example, ""
> is obviously a prefix of every string, but it is not very long. On the other
> hand, each string is a prefix of itself, but that prefix is shared by only
> one string (usually).
>
> By the way, the sort and compare adjacent pairs approach corresponds to
> "atLeastThisManyDescendants 2".

Ah, now the code makes sense to me. It's longer, but it is a heck of a
lot more principled and readable, so I'm happy to replace my version
with yours. It's not too hard to convert it into a CLI filter with
optional depth (default of 2, replicating original behavior):

import qualified Data.Map as Map
import System.Environment (getArgs)
import Data.List (sortBy)
import Data.Ord (comparing)

main :: IO ()
main = do arg <- getArgs
  let n = if null arg then 2 else read (head arg) :: Int
  interact (unlines .  chunk n . lines)

chunk :: Int -> [String] -> [String]
chunk n = map prefix . sortByLength . atLeastThisManyDescendants n . fromList
  where sortByLength :: [CommonPrefix Char] -> [CommonPrefix Char]
sortByLength = sortBy (comparing (numDescendant . names))
.

And the results seem kosher (printing just the prefixes is probably
the best idea, but wouldn't be too hard to switch to printing full
filenames - just filter the original file list with the extracted
prefix from each CommonPrefix):

$ ls music/vocaloid/| runhaskell lcp.hs 5
miku-s
miku-t
miku-r
rin-
miku-a
gumi-
luka-
$ ls music/vocaloid/| runhaskell lcp.hs 4
miku-h
miku-m
miku-n
miku-p
miku-s
miku-t
miku-r
rin-
miku-a
gumi-
luka-
$ ls music/vocaloid/| runhaskell lcp.hs # with 2
chorus-
gumi-mo
gumi-s
kaito-
luka-emon
luka-t
miku-acolorlinkingworld-
miku-akayaka
miku-cleantears-remind2011natsu-
miku-dan
miku-ele
miku-galaxyodyssey-
miku-ha
miku-inn
miku-jemappelle-motion-
miku-kz-
miku-lo
miku-m@rk-
miku-plustellia-壁の彩度-
miku-ro
miku-se
miku-ta
miku-the
miku-tinyparadise-
miku-ジラートP-birthdayofeden-
miku-杯本選
miku-般若心経
niconicochorus-
yuki-
len-
luka-di
miku-re:package-
miku-n
rin-

-- 
gwern
http://www.gwern.net
import qualified Data.Map as Map
import System.Environment (getArgs)
import Data.List (sortBy)
import Data.Ord (comparing)

main :: IO ()
main = do arg <- getArgs
  let n = if null arg then 2 else read (head arg) :: Int
  interact (unlines .  chunk n . lines)

chunk :: Int -> [String] -> [String]
chunk n = map prefix . sortByLength . atLeastThisManyDescendants n . fromList
  where sortByLength :: [CommonPrefix Char] -> [CommonPrefix Char]
sortByLength = sortBy (comparing (numDescendant . names))

-- A trie datatype
data Trie a = Trie { numLeafs, numDescendant :: !Int
   , children :: Map.Map a (Trie a) }

instance (Show a) => Show (Trie a) where
showsPrec _ t = showString "fromList " . shows (toList t)

-- The empty trie
empty :: Trie a
empty = Trie 0 0 Map.empty

-- A trie that contains a single string
singleton :: Ord a => [a] -> Trie a
singleton [] = Trie 1 1 Map.empty
singleton (x:xs) = Trie 0 1 (Map.singleton x (singleton xs))

-- Merge two tries
merge :: Ord a => Trie a -> Trie a -> Trie a
merge (Trie l d c) (Trie l' d' c')
= Trie (l+l') (d+d') (Map.unionWith merge c c')

fromList :: Ord a => [[a]] -> Trie a
fromList = foldr (merge . singleton) empty

toList :: Trie a -> [[a]]
toList (Trie l _ c)
= replicate l []
++ [ x:xs | (x,t) <- Map.toList c, xs <- toList t ]

data CommonPrefix a = Prefix { prefix :: [a], names :: Trie a }

instance (Show a) => Show (CommonPrefix a) where
showsPrec _ (Prefix p ns) = shows p . showString " ++ " . shows (toList ns)

-- Find prefixes that have at least minD descendants.
-- when there is a prefix xs with >=minD descendants, then shorter prefixes will not be returned
atLeastThisManyDescendants :: Int -> Trie a -> [CommonPrefix a]
atLeastThisManyDescendants minD trie@(Trie _ d c)
| d < minD = [] -- too few descendants
| null forChildren = [Prefix [] trie] -- all longer prefixes have too few descendants, but this prefix doesn't
| otherwise = forChildren -- there are longer prefixes with enough descendants, return them
  where
forChildren = [ Prefix (x:pfx) nms
  | (x,t) <- Map.toList c
  , Prefix pfx nms <- atLeastThisManyDescendants minD t ]

{- *Main> mapM_ (print . prefix) $ atLeastThisManyDescendants 4 test1
   "gumi-"
   "luka-"
   "miku-a"
   "miku-h"
   "miku-m"
   "miku-n"
   "miku-p"
   "miku-r"
   "miku-s"
   "miku-t"
   "rin-"
test1 :: Trie Char
test1 = fromList
  ["chorus-kiminoshiranaimonogatari.ogg"
  ,"chorus-mrmusic.ogg"
  ,"choucho-lastnightgoodnight.ogg"
  ,"dylanislame-aikotoba.ogg"
  ,"electriclove-エレクトリック・ラブ-korskremix.ogg"
  ,"gumi-bacon8-justhangingaround.ogg"
  ,"gumi-iapologizetoyou.ogg"
  ,"gumi-montblanc.ogg"
  ,

Re: [Haskell-cafe] Finding longest common prefixes in a list

2012-01-20 Thread Gwern Branwen
On Fri, Jan 20, 2012 at 1:57 PM, Twan van Laarhoven  wrote:
> Here is some example code (untested):

Well, you're right that it doesn't work. I tried to fix the crucial
function, 'atLeastThisManyDescendants', but it's missing something
because varying parts doesn't much affect the results when I try it
out on example input - it either returns everything or nothing, it
seems:

atLeastThisManyDescendants :: Int -> Trie a -> [CommonPrefix a]
atLeastThisManyDescendants minD trie@(Trie l d t')
   | d < minD = []
   | null forChildren = [Prefix [] trie]
   | otherwise = forChildren
 where
   forChildren = [ Prefix (x:pfx) nms
 | (x,t) <- Map.toList t'
 , Prefix pfx nms <- atLeastThisManyDescendants l t ]

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Finding longest common prefixes in a list

2012-01-20 Thread Gwern Branwen
Recently I wanted to sort through a large folder of varied files and
figure out what is a 'natural' folder to split out, where natural
means something like >4 files with the same prefix. (This might be
author, genre, subject, whatever I felt was important when I was
naming the file.) Now usually I name files with hyphens as the
delimiters like the hypothetical '1998-wadler-monads.pdf', and it
would be easy to write a stdin/stdout filter to break Strings on
hyphens and sort by whatever is most common. But this is rather
hardwired, can I solve the more general problem of finding the longest
common prefixes, whatever they are?

This turns out to be much more difficult than simply finding 'the'
longest common prefix (which is usually ""). I found an algorithm of
sorts at http://stackoverflow.com/a/6634624 but it was easier
described than implemented. Eventually I wrote what I *think* is a
correct program, but it's definitely of the write-only sort. Perhaps
people have better implementations somewhere? I saw a lot of
discussion of tries, but I didn't go that route.

The code, followed by an example:

#!/usr/bin/env runhaskell

import Data.List (intercalate, isPrefixOf, nub, sort)

main :: IO ()
main = interact (unlines . intercalate [""] . chunkFiles . lines )

-- basic algorithm from 
chunkFiles :: Ord a => [[a]] -> [[[a]]]
chunkFiles f = map (\(_,b) -> filter (isPrefixOf b) f) $ sort $
map (\x -> (countPrefixes x f,x)) (e $ bar f)

sharedPrefixes :: Ord a => [[a]] -> [a]
sharedPrefixes [] = []
sharedPrefixes s = foldr1 sp2 s
  where sp2 l1 l2 = map fst . takeWhile (uncurry (==)) $ zip l1 l2

traverse :: Ord a => [[a]] -> [[a]]
traverse [] = []
traverse x = sharedPrefixes (take 2 x) : traverse (drop 1 x)

bar :: Ord a => [[a]] -> [[a]]
bar = nub . sort . traverse . sort

countPrefixes :: (Ord a) => [a] -> [[a]] -> Int
countPrefixes x xs = length $ filter (x `isPrefixOf`) xs

e :: Eq a => [[a]] -> [[a]]
e y = map fst $ filter snd $ map (\x -> (x, (==) 1 $ length . filter
id $ map (x `isPrefixOf`) y)) y

{- Example input from `ls`:

chorus-kiminoshiranaimonogatari.ogg
chorus-mrmusic.ogg
choucho-lastnightgoodnight.ogg
dylanislame-aikotoba.ogg
electriclove-エレクトリック・ラブ-korskremix.ogg
gumi-bacon8-justhangingaround.ogg
gumi-iapologizetoyou.ogg
gumi-montblanc.ogg
gumi-mozaikrole.ogg
gumi-ハッピーシンセサイザ.ogg
gumi-showasengirl.ogg
gumi-sweetfloatflatsスイートフロートアパート.ogg
gumi-timewarpedafterchoppingmystagbeetle.ogg
gumi-オリジナル曲-付きホシメグリ.ogg
gumi-ミクオリジナル親友.ogg
kaito-byakkoyano.ogg
kaito-flowertail.ogg
kasaneteto-tam-ochamekinou重音テト吹っ切れたおちゃめ機能.ogg
len-crime-timetosaygoodbye.ogg
len-fire◎flower.ogg
len-ponponpon.ogg
lily-prototype.ogg
luka-apolxcore-waitingforyou.ogg
luka-dimトロイ.ogg
luka-dion-myheartwillgoon.ogg
luka-dirgefilozofio-dirgeasleepinjesus.ogg
luka-アゴアニキ-doubelariatダブルラリアット.ogg
luka-emon-heartbeats.ogg
luka-emonloid3-ハローハロー.ogg
luka-everybreathyoutake.ogg
luka-オリジナル-garden.ogg
luka-justbefriends.ogg
lukameiko-gemini.ogg
luka-milkyway.ogg
luka-やみくろ-かいぎ.ogg
luka-tic-tick.ogg
luka-torinouta.ogg
luka-zeijakukei-shounenshoujo.ogg
luka-勝手にアニメ-nologic-作ってみた.ogg
luka-駄目人間.ogg
meiko-artemis-awake.ogg
miku-9ronicleプラチナ.ogg
miku-acolorlinkingworld-この世界の下で.ogg
miku-acolorlinkingworld-青い花.ogg
miku-a+jugos-lullabyforkindness.ogg
miku-akayaka-beacon.ogg
miku-akayakap-sunrise.ogg
miku-aoihana.ogg
miku-arabianresponse.ogg
miku-avtechno-tear.ogg
miku-こえをきかせてcicci.ogg
miku-cleantears-remind2011natsu-greenhillzonecrystiararemix.ogg
miku-cleantears-remind2011natsu-夏影summerwindremix.ogg
miku-clocklockworks.ogg
miku-dancedancevol2-runner.ogg
miku-daniwellp-chaoticuniverse.ogg
miku-dixieflatline-shinonomescrumble.ogg
miku-electricloveエレクトリックラヴ.ogg
miku-elegumitokyo-kissmebaby.ogg
miku-galaxyodyssey-cryingirl.ogg
miku-galaxyodyssey-galaxyspacelines.ogg
miku-hakamairi.ogg
miku-haruna.ogg
miku-heartshooter.ogg
miku-hoshikuzutokakera.ogg
miku-innes.ogg
miku-innocence初音ミク.ogg
miku-jemappelle-motion-likeyou.ogg
miku-jemappelle-motion-ohwell.ogg
miku-jevannip-myfavoritesummer.ogg
miku-kakokyuudance-過呼吸ダンス.ogg
miku-kz-packaged.ogg
miku-kz-tellyourworld.ogg
miku-lastscene.ogg
miku-lostmemories付き-初音ミク.ogg
miku-lovelyday.ogg
miku-いいわけlove_song.ogg
mikulukagumi-prayfor.ogg
miku-maple-初音ミク楓-オリジナル曲.ogg
miku-more1.5.ogg
mik...@rk-eklosion.ogg
mik...@rk-kirch.ogg
miku-nana-ボーナストラック-ハッピー般若コア.ogg
miku-nekomimiswitch.ogg
miku-nightrainbow.ogg
miku-noyounome.ogg
miku-むかしむかしのきょうのぼくオリジナル.ogg
miku-pandolistp-neverendinghammertime.ogg
miku-ジラートP-birthdayofeden-deepsleep.ogg
miku-ジラートP-birthdayofeden-水中読書.ogg
miku-plustellia-dear.ogg
miku-plustellia-壁の彩度-crazygirl.ogg
miku-plustellia-壁の彩度-discoradio.ogg
miku-ぽわぽわP-ストロボライト.ogg
miku-rabbitforgets.ogg
miku-re:package-lastnightgoodnight.ogg
miku-re:package-ourmusic.ogg
miku-re:package-sutorobonaitsu.ogg
miku-rollinggirl.ogg
miku-ryo-メルト-melt.ogg
miku-senseiniitteyaro.ogg
miku-sevencolors-レモネード.ogg
miku-shoukinosatadenia.ogg
miku-stratosphere.ogg
miku-supernova.ogg
miku-t

Re: [Haskell-cafe] Pattern-matching & substitution for haskell-src-exts?

2012-01-18 Thread Gwern Branwen
On Wed, Jan 18, 2012 at 3:05 PM, Conal Elliott  wrote:
> Has anyone implemented pattern-matching & substitution for
> haskell-src-exts?  - Conal

I don't know what exactly you are looking for, but I remember banging
together a function-name search script using haskell-src-exts and
'find' last summer, which pattern-matches, looking for use of
particular function-names. Presumably you could change
`functionSearch` to not call `length` but instead replace the matched
function with another function and then write out the modules? Well,
maybe the source will be helpful, maybe not:

import System.Environment (getArgs)
import Language.Haskell.Exts
import qualified Data.Foldable as F (concat)
import Data.Generics.Uniplate.Data
-- import Debug.Trace

main :: IO ()
main = do (func:_) <- getArgs
  args <- fmap lines $ getContents
  mapM_ (checkAndPrint func) args

checkAndPrint :: String -> FilePath -> IO ()
checkAndPrint fn fs = do print fs
 x <- readFile fs
 let exts = F.concat $ readExtensions x
 let parsed = parseFileContentsWithMode
(defaultParseMode { fixities = fixes, extensions = exts }) x
 case parsed of
  ParseFailed _ _ -> (return ())
  ParseOk a -> functionSearch fn a
 return ()

-- the default fixities augmented with everything necessary to parse my corpus
fixes :: Maybe [Fixity]
fixes = Just $ baseFixities ++ infixr_ 0 ["==>"]

functionSearch :: String -> Module -> IO ()
functionSearch fun md = do
  let x = length [ () | Var (UnQual (Ident a)) <- universeBi md, a == fun]
  putStrLn $ "Found " ++ show x ++ " occurences of function " ++ fun

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Haskell Summers of Code retrospective (updated for 2011)

2011-12-10 Thread Gwern Branwen
The Wheel turns, and months come and pass, leaving blog posts that
fade into 404s; a wind rose in Mountain View, whispering of the coming
Winter...

Tonight I sat down and finally looked into the 2011 SoCs to see how
they turned out and judge them according to my whimsically arbitrary
and subjective standards:
http://www.gwern.net/Haskell%20Summer%20of%20Code#results-1

They turned out pretty much as I predicted - but then I *would* say
that, wouldn't I?

(Also submitted to /r/haskell for those who swing that way:
http://www.reddit.com/r/haskell/comments/n82ln/summer_of_code_2011_retrospective/
)

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Google Knol and haskellers

2011-10-13 Thread Gwern Branwen
On Thu, Oct 13, 2011 at 11:52 AM, Sean Leather  wrote:
> On Wed, Oct 12, 2011 at 12:35, Yves Parès wrote:
>>
>> I re-head recently about Google Knol, which is IMO some crossing-over
>> between a wiki and a blog.
>> Are there some people that use it here to write haskell-related articles
>> instead of a regular blog?
>
> As far as anybody outside Google knows, Knol has pretty much been abandoned.
> See http://googlesystem.blogspot.com/2011/01/abandoned-knol.html . I don't
> think it's worth contributing knowledge to it.

I agree; I predicted back in January 2009 that it would fail to go
anywhere, and checking up on it, I find that none of the stats have
improved since then:
http://www.gwern.net/Wikipedia%20and%20Knol#knol-did-fail

Indeed, the real question for me is when it will officially die:
http://www.gwern.net/Wikipedia%20and%20Knol#knol-death-watch

Knol has zero advantages over the Haskell wiki, and never has, unless
you want fanatical control of your content and miniscule ad content,
in which case you are better off with your own blog.

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Solving the configuration problem with parametrized modules

2011-09-05 Thread Gwern Branwen
On Mon, Sep 5, 2011 at 1:43 PM, Joachim Breitner
 wrote:
> Do you think this could be useful (from a user point of view)? Has this
> idea maybe already been proposed?

How does it compare with Oleg's typeclass approach?
http://okmij.org/ftp/Haskell/types.html#Prepose

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Truly Really Off-topic: (Was: Mathematics)

2011-08-29 Thread Gwern Branwen
On Mon, Aug 29, 2011 at 11:47 AM, Gwern Branwen  wrote:
> As well, in no Google hit did I find any specific citation to
> Dijkstra. Hence, I conclude that because it is insightful and sounds
> like Dijkstra (eg. his submarine quote), it has become apocryphally
> associated with him but is *not* actually a Dijkstra quote.

To follow up:

- 'telescopes' does not appear anywhere in the EWDs:
http://ewd.cs.utexas.edu.master.com/texis/master/search/?sufs=0&q=telescopes&xsubmit=Search&s=SS
- Ruud Koot points to an August* 1993 PhD thesis
(http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.53.8045&rep=rep1&type=pdf)
which attributes it, with no citation or sourcing information, to
Dijkstra
- a Redditor claims, with no citation or sourcing information, that it
was Marvin Minsky
(http://www.reddit.com/r/programming/comments/jy1zw/psa_dijkstra_did_not_say_computer_science_is_no/c2g17xt)

* that is, well after the original January 1993 article

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Truly Really Off-topic: (Was: Mathematics)

2011-08-29 Thread Gwern Branwen
On Mon, Aug 29, 2011 at 12:18 PM, aditya siram  wrote:
> I'm afraid you're going to have a lot of OCD's completely miss the point of
> your email and annoy you with comments about the quote which you'll then
> have to refute.

I dunno, I found the quote interesting. I had typed up a scornful
response to the effect that everyone knows it's a Dijkstra quote and
he could find sourcing in seconds with Google, but as the seconds
passed, I had to rewrite the seconds bit, then as I found actual
cites, I had to rewrite the Dijkstra bit, and then I realized that
replying to that email might take a while...

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Truly Really Off-topic: (Was: Mathematics)

2011-08-29 Thread Gwern Branwen
On Mon, Aug 29, 2011 at 11:19 AM, Jerzy Karczmarczuk
 wrote:
> It is unsourced, repeated without discernment, and Dijkstra cannot confirm
> (or deny) it any more. Somehow I cannot believe he said that...
> Dijkstra began to study physics, and a physicist would be reluctant to make
> such puns. Why?

Some googling takes me to the full quote:

> "Computer science is no more about computers than astronomy is about 
> telescopes, biology is about microscopes, or chemistry is about beakers and 
> test tubes. Science is not about tools. It is about how we use them, and what 
> we find out when we do."

Which is referenced to, inside _Invitation to Computer Science_ (G.
Michael Schneider, Judith L. Gersting, Keith Miller;
http://books.google.com/books?id=gQK0pJONyhgC ), to "Fellows, M.R.,
and Parberry, I. "Getting Children Excited About Computer Science",
_Computing Research News_, vol. 5, no. 1 (January 1993)".

Curiously, the preface to the quote is:

> This distinction between computers and computer science is beautifully 
> expressed by computer scientists Michael R. Fellows and Ian Parberry in an 
> article in the journal _Computing Research News_:

*No* mention of Dijkstra. Searching that full book, the only Dijkstra
mentions are unconnected to the quote.

Chasing links, I head to
http://archive.cra.org/CRN/issues/by_title_by_issue.html and download
January 1993: http://archive.cra.org/CRN/issues/9301.pdf

On page 7, I find it. The article title is different: "SIGACT trying
to get children excited about CS". The money line is highlighted. The
relevant paragraph and surrounding paragraphs:

> Is it any wonder then that computer science is represented in many schools by 
> either computer games or some antiquated approach to programming, which at 
> worst concentrates on a litany of syntax and at best emphasizes expediency 
> over effectiveness and efficiency? But computer science is not about 
> computers—it is about computation.
>
> What would we like our children- the general public of the future—to learn 
> about computer science in schools? We need to do away with the myth that 
> computer science is about computers. Computer science is no more about 
> computers than astronomy is about telescopes, biology is about microscopes or 
> chemistry is about beakers and test tubes. Science is not about tools, it is 
> about how we use them and what we find out when we do.
>
> It may come as a surprise to some that computer science is full of activities 
> that children still find exciting even without the use of computers. Take 
> theoretical computer science, for example, which may seem an unlikely 
> candidate. If computer science is underrepresented in schools, then 
> theoretical computer science is doubly so.

This is the precise quote, with no quotation marks or references or
allusions of any kind; this seems to be the original, where the exact
quote comes from. There are no mentions whatsoever of Dijkstra in the
January PDF.

On Mon, Aug 29, 2011 at 11:25 AM, Christopher Done
 wrote:
> Wherever its origin, it is featured in SICP which was out in 1984:
> http://www.youtube.com/watch?v=zQLUPjefuWA It's a sound analogy.

Abelson doesn't cite Dijkstra in the first minute where he makes the
comparisons, either, unless I missed it.

As well, in no Google hit did I find any specific citation to
Dijkstra. Hence, I conclude that because it is insightful and sounds
like Dijkstra (eg. his submarine quote), it has become apocryphally
associated with him but is *not* actually a Dijkstra quote.

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Parsing cabal files to calculate average number of dependencies

2011-07-09 Thread Gwern Branwen
On Fri, Jul 1, 2011 at 5:37 PM, Gwern Branwen  wrote:
> Looking at it, the index tarball contains the .cabal files for all
> versions known to Hackage, which isn't necessarily the interesting set
> of cabal files - I'm usually more interested in just the cabal files
> of the latest version of every package. No doubt there's a scripting
> solution (loop over the untarred directory of packages, and take the
> lexically last cabal file?), but it was easier to just exploit cabal
> fetch's behavior of fetching only the latest version and work with
> those tarballs.

The version using just the index tarball is kind of ugly; the
filtering and extracting doesn't seem terribly easy, so the best
script I could come up with was:

cd ~/.cabal/packages/hackage.haskell.org && for DIR in */; do (for
CABAL in `tar --wildcards "$DIR" -tf 00-index.tar|head -1`; do (tar
-Oxf 00-index.tar $CABAL | runhaskell ~/deps.hs); done); done

(Parentheses aren't necessary but make it more readable.)

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Parsing cabal files to calculate average number of dependencies

2011-07-01 Thread Gwern Branwen
Another thing you can do along the same lines is generate a script to
download all the repos from packages which declare repos. Some ugly
code:

import Data.Maybe (fromJust)
import Distribution.PackageDescription
import Distribution.PackageDescription.Parse
import Control.Monad (unless)

main :: IO ()
main = do cbl <- getContents
  let desc = parsePackageDescription cbl
  case desc of
ParseFailed _ -> return ()
ParseOk _ d -> do let repos = repoPair $ extractHead $
extractRepos d
  let cmd = concatMap shellify repos
  unless (null cmd) $ putStrLn cmd

shellify :: (RepoType, String) -> String
shellify (rt,url) = case rt of
   Darcs -> "darcs get " ++ url
   Git -> "git clone " ++ url
   SVN -> "svn clone " ++ url
   CVS -> "cvs co " ++ url
   Mercurial -> "hg clone " ++ url
   _ -> ""

repoPair :: [SourceRepo] -> [(RepoType, String)]
repoPair = map (\x -> (fromJust $ repoType x, fromJust $ repoLocation x))

extractHead :: [SourceRepo] -> [SourceRepo]
extractHead rs = filter (\x -> isnothing x && ishead x) rs
where ishead sr = case repoKind sr of
RepoHead -> True
_ -> False
  isnothing ss = case repoType ss of
   Nothing -> False
   Just _ -> case repoLocation ss of
 Nothing -> False
 Just _ -> True

extractRepos :: GenericPackageDescription -> [SourceRepo]
extractRepos = sourceRepos . packageDescription

This generates results (with the same find command and setup as
previously) like:

...
git clone git://gitorious.org/maximus/mandulia.git
darcs get http://darcs.cielonegro.org/HsOpenSSL/
darcs get http://darcs.cielonegro.org/HsOpenSSL/
hg clone https://bitbucket.org/bos/text-icugit clone
https://github.com/bos/text-icu
darcs get http://code.haskell.org/Graphalyze
darcs get http://code.haskell.org/~roelvandijk/code/base-unicode-symbols
git clone git://github.com/roelvandijk/base-unicode-symbols.git
darcs get http://code.haskell.org/~basvandijk/code/regions
git clone https://github.com/skogsbaer/xmlgen
git clone git://github.com/tanakh/HongoDB.git
darcs get http://repos.mornfall.net/shellish
darcs get http://patch-tag.com/r/Saizan/syb-with-class/
git clone git://github.com/ekmett/eq.git
git clone git://github.com/ekmett/data-lens-fd.git
git clone git://github.com/ekmett/streams.git
git clone git://github.com/alanz/hjsmin.git
darcs get http://patch-tag.com/r/byorgey/diagrams-lib
...

--
gwern
http://www.gwern.net/haskell/Archiving%20GitHub

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Parsing cabal files to calculate average number of dependencies

2011-07-01 Thread Gwern Branwen
On Fri, Jul 1, 2011 at 5:23 PM, Rogan Creswick  wrote:
>
> I think the index tarball has all the info you need, and would be
> faster to retrieve / process, if you or anyone else needs to get the
> .cabal files again:
>
> http://hackage.haskell.org/packages/archive/00-index.tar.gz (2.2mb)

Looking at it, the index tarball contains the .cabal files for all
versions known to Hackage, which isn't necessarily the interesting set
of cabal files - I'm usually more interested in just the cabal files
of the latest version of every package. No doubt there's a scripting
solution (loop over the untarred directory of packages, and take the
lexically last cabal file?), but it was easier to just exploit cabal
fetch's behavior of fetching only the latest version and work with
those tarballs.

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Parsing cabal files to calculate average number of dependencies

2011-07-01 Thread Gwern Branwen
On Fri, Jul 1, 2011 at 4:49 PM, L Corbijn  wrote:
> Is this including or exluding 'or'-ed dependency lists like
> http://hackage.haskell.org/package/hugs2yc ?

Excluding, it seems. When I run the script on that tarball:

$ tar --wildcards "*.cabal" -Oxf `find . -name "*.tar.gz" | g hugs2yc`
| runhaskell /home/gwern/deps.hs
PackageName "mtl"
PackageName "uniplate"
PackageName "yhccore"
PackageName "ycextra"
PackageName "parsec"
PackageName "directory"
PackageName "filepath"

No version of base or containers appears. (mtl appears in both
branches and also the general build-depends list.)

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Parsing cabal files to calculate average number of dependencies

2011-07-01 Thread Gwern Branwen
Athas on #haskell wondered how many dependencies the average Haskell
package had. I commented that it seemed like some fairly simple
scripting to find out, and as these things tend to go, I wound up
doing a complete solution myself.

First, we get most/all of Hackage locally to examine, as tarballs:

for package in `cabal list | grep '\*' | tr -d '\*'`; do cabal
fetch $package; done

Then we cd .cabal/packages/hackage.haskell.org

Now we can run a command which extracts the .cabal file from each
tarball to standard output:

find . -name "*.tar.gz" -exec tar --wildcards "*.cabal" -Oxf {} \;

We could grep for 'build-depends' or something, but that gives
unreliable dirty results. (>80k items, resulting in a hard to believe
87k total deps and an average of 27 deps.) So instead, we use the
Cabal library and write a program to parse Cabal files & spit out the
dependencies, and we feed each .cabal into that:

find . -name "*.tar.gz" -exec sh -c 'tar --wildcards "*.cabal"
-Oxf {} | runhaskell ~/deps.hs' \;

And what is deps.hs? Turns out to be surprisingly easy to parse a
String, extract the Library and Executable AST, and grab the
[Dependency] field, and then print it out (code is not particularly
clean):

import Distribution.Package
import Distribution.PackageDescription
import Distribution.PackageDescription.Parse
main :: IO ()
main = do cbl <- getContents
  let desc = parsePackageDescription cbl
  case desc of
ParseFailed _ -> return ()
ParseOk _ d -> putStr $ unlines $ map show $ map
(\(Dependency x _) -> x) $ extractDeps d
extractDeps :: GenericPackageDescription -> [Dependency]
extractDeps d = ldeps ++ edeps
  where ldeps = case (condLibrary d) of
Nothing -> []
Just c -> condTreeConstraints c
edeps = concat $ map (condTreeConstraints . snd) $ condExecutables d

So what are the results? (The output of one run is attached.) I get
18,134 dependencies, having run on 3,137 files, or 5.8 dependencies
per package.

-- 
gwern
http://www.gwern.net


deps.txt.gz
Description: GNU Zip compressed data
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] haskellwiki slow/unresponsive

2011-06-06 Thread Gwern Branwen
On Mon, Jun 6, 2011 at 4:45 PM, Greg Weber  wrote:

> Gitit uses darcs or git to store data, but through the command line
> interfaces. Unfortunately to my knowledge darcs does not expose a library
> interface. Gitit could be made faster and more secure by interfacing with
> libgit2.

Darcs does export a library and pretty much has ever since I first
cabalized it; see http://hackage.haskell.org/package/darcs for the
module listings. It's not a very useful API, however. I don't know how
to use it, and John doesn't know how to use libgit2, I suspect.

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] haskellwiki slow/unresponsive

2011-06-03 Thread Gwern Branwen
On Fri, Jun 3, 2011 at 4:17 PM, Eric Rasmussen  wrote:
> This is a bit of a tangent, but has anyone developed wiki software in
> Haskell?

Gitit is the most developed one, and it's been suggested in the past
that hawiki move over. It's not a good idea for a couple reasons,
which I've said before but I'll repeat here:

1. Performance; there have been major issues with the Darcs backend,
though mostly resolved, and we don't know how well the Git backend
would scale either. Gitit has mostly been used with single-users (how
I use it) or projects with light traffic (wiki.darcs.net). I don't
know why hawiki is slow, but whatever it is is probably either
hardware or configuration related - MediaWiki after all powers one of
the most popular websites in the world.
2. Security; there have been big holes in Gitit. Some of it is simple
immaturity, some of it due to the DVCS backends. Where there is one
hole, there are probably more - if there aren't holes in the Gitit
code proper, there probably are some in Happstack. There's no reason
to think there aren't: security is extremely hard. And in that
respect, Mediawiki is simply much more battle-tested. (Most popular
websites in the world, again, and one that particularly invites abuse
and attack.)
3. The existing hawiki content is Mediawiki centric, relying on
templates and MW syntax etc. Templates alone would have to be
implemented somehow, and Pandoc's MW parser is, last I heard, pretty
limited.

Gitit is great for what it is, and I like using it - but it's not
something I would rely on for anything vital, and especially not for
something which might be attacked. (This isn't paranoia; I deal with
spammers every day on hawiki, and c.h.o was rooted recently enough
that the memory should still be fresh in our collective minds.)

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] lambdabot hoogle

2011-05-25 Thread Gwern Branwen
On Wed, May 25, 2011 at 11:08 AM, Jacek Generowicz
 wrote:
> Quite possibly not, but it would it be too much to ask, to have the
> documentation mention that they need to be installed separately if you
> intend to use them through lambdabot?

I've just added them to the dependencies.

> I've already stumbled across mueval and hoogle as things that need to be
> installed separately before the full advertized features of lambdabot work.
>
> With this experience under my belt and the benefit of hindsight, I vaguely,
> almost, kinda, maybe see how I could have guessed that the stubborn response
> "A Hoogle error occurred." to any hoogle command in lambdabot, means that I
> need to install hoogle locally:
>
> 'hoogle ...' --> "A Hoogle error occurred." ==> install hoogle.
>
> But how on earth was I supposed to guess that in order to make 'check' work,
> the package to install was 'mueval', given that the error message was
> "Terminated"?
>
> 'check ...' --> "Terminated" ==> install mueval.

You weren't really meant to - lambdabot isn't exactly meant for anyone
who won't look at the source when something goes wrong. It's only
half-maintained by me; I do easy fixes but nothing else since the
lambdabot codebase is large and IMO rotten.

> Hmmm.
>
> What other lambdabot features rely on packages that need to be installed
> separately?

Brainfuck and unlambda are separate executables, but they already have deps.

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] lambdabot hoogle

2011-05-25 Thread Gwern Branwen
On Wed, May 25, 2011 at 6:22 AM, Jacek Generowicz
 wrote:
> I had assumed that it connected to a server.

It did at one point, but Hoogle had downtime and the local hoogle
command was just as good and worked offline.

> (Maybe my assumption was not entirely unfounded, given that the installation
> instructions for lambdabot blithely state that you "just cabal install
> lambdabot", nowhere suggesting that you might need to *manually* install
> some of its dependencies.)

Well, does every lambdabot user want mueval and hoogle installed? In
those specific cases because they export libraries as well, I could
add a dependency on the library; but cabal doesn't support
dependencies for pure executable packages.

> Once I have the hoogle command line version working, it seems that lambdabot
> truncates its output to just the first 3 lines. Is this normal? Is there a
> way of customizing or changing this behaviour?

It's normal, yeah. Don't want to spam #haskell with 100 lines of
useless matches. Configurable? Not really.

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] lambdabot check

2011-05-24 Thread Gwern Branwen
On Tue, May 24, 2011 at 7:00 AM, Jacek Generowicz
 wrote:
> I've installed lambdabot, but check within it seems to be broken: the only
> answer it ever gives is "Terminated". For example:
>
> lambdabot> check True
>  Terminated
> lambdabot>
>
>
>
> quickCheck works just fine in a GHCi session:
>
>
> Prelude> :m + Test.QuickCheck
> [...]
> Prelude> quickCheck True
> [...]
> +++ OK, passed 100 tests.

@check these days goes through mueval. Are you sure mueval is
installed & working? You can try running the tests.sh script which
will exercise the QuickCheck functionality among other things.

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Downloading Haskell repos from GitHub

2011-03-20 Thread Gwern Branwen
On Fri, Apr 30, 2010 at 12:02 PM, Gwern Branwen  wrote:
> On Fri, Apr 30, 2010 at 11:51 AM, Jesper Louis Andersen
>  wrote:
>> On Fri, Apr 30, 2010 at 5:38 PM, Gwern Branwen  wrote:
>>> Nothing in http://develop.github.com/ seems especially useful for
>>> grabbing the git:// URLs of all repos by language - just by user.
>>>
>>> The only real list of repos by language seems to be gotten at via
>>> http://github.com/languages/Haskell/updated or
>>> http://github.com/languages/Haskell/created . (You might think
>>> http://github.com/languages/Haskell would be good, but no, it's just a
>>> few random repos by interest and not a full listing.)
>>
>> Github has a REST API for accessing data. Unfortunately it can't give
>> you the wanted
>> breakdown, but I would ask them for it. It is much simpler for you,
>
> You mean ask for a new feature? (Just a one-time list is no good since
> I intend to repeat it regularly to pick up new repos, just like with
> patch-tag.)
>
>> and it does not put an extra strain on their servers due to the
>> scraping.
>
> Well, it'd only be about 2000 HTTP hits. (98 + (20 * 98)). The
> downloading of the repos would probably reduce that demand to
> insignificance, especially the first time around when most of the
> repos would need to be downloaded.
>
>> Usually, the github guys are helpful when you have a
>> question.

Ultimately, they never did anything about it:
http://support.github.com/discussions/email/6782-contact-extending-api-to-easily-get-list-of-repos-by-language

So I wrote a TagSoup scraper; then I wrote a long tutorial explaining
how I wrote it, step by step.

1. my tutorial: http://www.gwern.net/haskell/Archiving%20GitHub.html
2. the script itself:
http://www.gwern.net/haskell/Archiving%20GitHub.html#the-script
3. Reddit submission of #1 for those who prefer to comment there:
http://www.reddit.com/r/haskell/comments/g7na5/writing_a_haskell_script_to_download_github/

(While writing the tutorial, I tweaked the script code, so I'm not
100% confident that it still works - it uses too much GitHub bandwidth
(and local disk space) for me to re-run it just to see whether it
still works. So if anyone does run it, I would appreciate knowing
whether it still works.)

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: unordered-containers - a new, faster hashing-based containers library

2011-02-23 Thread Gwern Branwen
On Wed, Feb 23, 2011 at 1:18 PM, Johan Tibell  wrote:
>
> Could you manually look at some of them to see if you find something
> interesting. In particular `Set.size s == 0` (a common use of size in
> imperative languages) could be replaced by `Set.null s`.

You could look at them yourself; I attached the files. I see 6 uses
out of ~100 which involve an == 0

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why is there no "splitSeperator" function in Data.List

2011-02-12 Thread Gwern Branwen
On Sat, Feb 12, 2011 at 11:00 AM, Robert Clausecker  wrote:
> Is there any reason, that one can't find a function that splits a list
> at a seperator in the standard library? I imagined something like this:
>
>
>    splitSeperator :: Eq a => a -> [a] -> [[a]]
>
>    splitSeperator ',' "foo,bar,baz"
>      --> ["foo","bar","baz"]
>
> Or something similar? This is needed so often, even if I can implement
> it in one line, is there any reason why it's not in the libs?

See http://hackage.haskell.org/package/split

The reason it's not in Data.List is because there are a bazillion
different splits one might want (when I was pondering the issue before
Brent released it, I had collected something like 8 different proposed
splits), so no agreement could ever be reached.

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Haskell Summers of Code retrospective (updated for 2010)

2011-02-09 Thread Gwern Branwen
2 years ago in February 2009, I wrote up a history of Summers of Code
through 2008 
(http://www.haskell.org/pipermail/haskell-cafe/2009-February/055489.html).
But the Wheel turns, and years come and pass, leaving memories that
fade into 404s; a wind rose in Mountain View, whispering of the coming
Summer...

I have considerably expanded and updated the coverage:
http://www.gwern.net/Haskell%20Summer%20of%20Code.html

It now covers the 2009 & 2010 SoCs, adds scads of links, flips the
appraisal of some of the older SoCs as time passed and more info came
to light, and adds a section discussing 12 proposals from the
subreddit & Trac.

(It's long enough that I don't feel comfortable copying it inline as I
did 2 years ago.)

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Problem with xhtml 1.5.1.1: html tags are split

2011-02-05 Thread Gwern Branwen
On Thu, May 13, 2010 at 11:38 AM, Gwern Branwen  wrote:
> On Tue, May 11, 2010 at 3:00 AM, Bjorn Bringert  wrote:
>> I support finding a new maintainer.
>
> Alright; as the old maintainer, I guess it falls on you to advertise
> on -cafe and libraries.

Has a request gone out yet? I didn't notice anything (maybe it got
lost in all the recent haskell.org downtime), and the current Hackage
page of xhtml is still listing Bjorn.

Anyway, John MacFarlane has found a workaround which he's implemented
in HEAD Pandoc (http://code.google.com/p/pandoc/issues/detail?id=134);
from 
http://groups.google.com/group/pandoc-discuss/browse_frm/thread/915586b5c5e264b6#
:

> Many people have wanted pandoc to produce "more normal" HTML output,
> without nesting, but with line breaks between block elements (where
> they aren't semantically significant). Something like this:
>
> 
> a link
> another list item
> 
>
> I've found that I can get this kind of output, even using Text.XHtml's
> renderer, by modifying the writer to insert raw newlines after block
> elements, and using 'showHtmlFragment' rather than 'prettyHtmlFragment'.

This may be useful for other people to know. (There are quite a few
users of xhtml:
http://bifunctor.homelinux.net/~roel/cgi-bin/hackage-scripts/revdeps/xhtml-3000.2.0.1#direct
)

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Automatically move cursor focus in split window in haskell-mode in emacs on load (C-c C-l) command?

2011-01-30 Thread Gwern Branwen
On Sun, Jan 30, 2011 at 11:30 AM, JETkoten  wrote:

> The way it defaults to now is that the cursor stays in the topmost editing
> half of the split screen, and I inevitably begin typing and mess up my code
> and have to do some backspacing and then mouse over to the bottom half.
>
> :)
>
> I checked on #haskell and #emacs last night, and someone suggested either
> "doing it with elisp" or keyboard macros, but I'm not sure how to do the
> first, and I think the second is not what I'm looking for.
>
> I'd like for haskell-mode to otherwise remain the same, and to still use the
> same C-c C-l key sequence, but I'd just like it to always be set up to add
> the step in the load sequence of jumping the cursor focus down to the lower
> half of the split for me.

>From my .emacs;

   ;Default behaviour is to always
jump to the GHCi window.
   ;Jump back automatically unless errors.
   (defadvice haskell-ghci-load-file
(after name)
 (other-window 1))
   (ad-activate 'haskell-ghci-load-file t)

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Building lambdabot

2011-01-20 Thread Gwern Branwen
On Thu, Jan 20, 2011 at 5:33 PM, Max Bolingbroke
 wrote:
> On 20 January 2011 20:50, Gwern Branwen  wrote:
>> Notice the flag defaults to False, not True. When I tried it with True, I 
>> got:
>>
>> $ cabal install
>> Resolving dependencies...
>> cabal: dependencies conflict: base-3.0.3.2 requires syb ==0.1.0.2 however
>> syb-0.1.0.2 was excluded because syb-0.3 was selected instead
>> syb-0.1.0.2 was excluded because show-0.4.1 requires syb ==0.3.*
>
> Suprising. It certainly seems to contradict my understanding of how
> Cabal works (which is derived from
> http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#conditional-resolution)
>
> Anyway, I'm glad that you have recorded a patch which at least gives
> GHC 7 a chance of working. If I knew where the repo was I would try it
> out (it doesn't seem to be linked anywhere from
> http://hackage.haskell.org/packages/archive/show/0.4.1/show.cabal).

It's just a folder in the lambdabot repo, as is lambdabot-utils and
unlambda and brainfuck.

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Building lambdabot

2011-01-20 Thread Gwern Branwen
On Thu, Jan 20, 2011 at 12:45 PM, Max Bolingbroke
 wrote:
> On 20 January 2011 17:30, Gwern Branwen  wrote:
>>> * You need to loosen the base upper bound to < 4.4
>>> * If using base >= 4, you need to depend on the syb package as well
>>> (current version 0.3)
>>
>> Would this break GHC 6.12 builds?
>
> Thats why I suggested the flag stanza. Cabal has a weird kind of flag
> semantics where it will try every possible combination of flags until
> it finds one that builds. The solution I suggested uses this behaviour
> to either depend on base >= 4 && < 4.4 WITH syb, OR base < 4 WITHOUT
> syb. Because of the default flag setting of True, the first
> possibility will be tried first, but it if fails Cabal will just fall
> back on base < 4.
>
> In short, it should work perfectly for either GHC 7 or 6.12 clients
> (modulo syntax issues - I haven't actually tried the syntax I sent
> you).

No, there's another issue. I've recorded this version;

hunk ./show/show.cabal 25
+Flag base4
+ Description: Build with base-4
+ Default: False
+
hunk ./show/show.cabal 32
-   build-depends:   base<4, random, QuickCheck>=2.4, smallcheck>=0.4
+   build-depends:   random, QuickCheck>=2.4, smallcheck>=0.4
+   if flag(base4)
+build-depends:   base>=4 && <4.4, syb >= 0.3 && < 0.4
+   else
+build-depends:   base<4

Notice the flag defaults to False, not True. When I tried it with True, I got:

$ cabal install
Resolving dependencies...
cabal: dependencies conflict: base-3.0.3.2 requires syb ==0.1.0.2 however
syb-0.1.0.2 was excluded because syb-0.3 was selected instead
syb-0.1.0.2 was excluded because show-0.4.1 requires syb ==0.3.*

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Building lambdabot

2011-01-20 Thread Gwern Branwen
On Thu, Jan 20, 2011 at 3:24 AM, Max Bolingbroke
 wrote:
> On 20 January 2011 01:51, Gwern Branwen  wrote:
>> It had a lot of issues which meant it wouldn't build anywhere, where
>> at least the Hackage version worked at some point. I spent this
>> evening working on fixing issues (rewriting the show package to use
>> QuickCheck 2 rather than QuickCheck 1 was not fun!) and have uploaded
>> a lambdabot and show that compile for me on GHC 6.12.1
>
> The show package almost compiles on GHC 7, but:
>
> * You need to loosen the base upper bound to < 4.4
> * If using base >= 4, you need to depend on the syb package as well
> (current version 0.3)

Would this break GHC 6.12 builds? Since I do not have GHC 7 installed
and, given the breakage I experienced when I installed it the other
day and tried to cabal-install my usual tools, will not have it
installed any time soon, I am leery of any GHC 7-related changes.

data-memocombinators is only the tip of the iceberg; I believe much of
lambdabot would need modifications. (Apparently Control.OldException
has gone away, which alone guarantees many changes.) So there wouldn't
be much point to changing show.

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Building lambdabot

2011-01-19 Thread Gwern Branwen
On Tue, Jan 18, 2011 at 3:41 PM, Max Bolingbroke
 wrote:
> That sounds like a good thing to do. Also, oo you know if there's any
> reason that the most recent lambdabot is not pushed to Hackage? That
> might make things even easier for others who wish to install it. It
> certainly confused me!
>
> Cheers,
> Max

It had a lot of issues which meant it wouldn't build anywhere, where
at least the Hackage version worked at some point. I spent this
evening working on fixing issues (rewriting the show package to use
QuickCheck 2 rather than QuickCheck 1 was not fun!) and have uploaded
a lambdabot and show that compile for me on GHC 6.12.1

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Building lambdabot

2011-01-07 Thread Gwern Branwen
On Fri, Jan 7, 2011 at 11:00 AM, Max Bolingbroke
 wrote:
>
> Well, I tried to see if I could reproduce your problem but didn't get
> to this stage. It looks like v4.2.2.1 from Hackage hasn't been updated
> for donkeys years and breaks massively because of at least the new
> exceptions library, mtl 2.0 and the syb package being split off from
> base.

I haven't commented before because most of the issues seemed to be Mac
specific, which I know nothing about, but avoid the Hackage packages
for lambdabot. You should be working out of darcs for lambdabot and
its split-out packages like show or unlambda:
http://code.haskell.org/lambdabot/

Darcs lambdabot ought to work reasonably well with GHC 6.12.1, which
is what I have.

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANN: archiver 0.1 and 0.2

2010-12-10 Thread Gwern Branwen
I'd like to announce a small utility and library which builds on my
WebArchive plugin for gitit: archiver
http://hackage.haskell.org/package/archiver Source is available via
`darcs get http://community.haskell.org/~gwern/archiver/`.

The library half is a simple wrapper around the appropriate HTTP
requests; the executable half reads a text file and loops as it
(slowly) fires off requests and deletes the appropriate URL.

That is, 'archiver' is a daemon which will process a specified text
file, each line of which is a URL, and will one by one request that
the URLs be archived or spidered by http://www.webcitation.org * and
http://www.archive.org ** for future reference. That is, WebCite and
the IA will store a copy of the HTML and hopefully all the non-dynamic
resources the web pages need. (An example would be
http://bits.blogs.nytimes.com/2010/12/07/palm-is-far-from-game-over-says-former-chief/
and http://webcitation.org/5ur7ifr12)

Usage of archiver might look like `while true; do archiver ~/.urls.txt
gwe...@gmail.com; done`***.

There are a number of ways to populate the source text file. For
example, I have a script `firefox-urls` which is called in my crontab
every hour, and which looks like this:

#!/bin/sh
set -e
cp `find ~/.mozilla/ -name "places.sqlite"` ~/
sqlite3 places.sqlite "SELECT url FROM moz_places, moz_historyvisits \
   WHERE moz_places.id =
moz_historyvisits.place_id and visit_date > strftime('%s','now','-1
day')*100 ORDER by \
   visit_date;" >> ~/.urls.txt
rm ~/places.sqlite

This gets all visited URLs in the last time period and prints them out
to the file for archiver to process. Hence, everything I browse is
backed-up.

More useful perhaps is a script to extract external links from
Markdown files and print them to stdout:

import System.Environment (getArgs)
import Text.Pandoc (defaultParserState, processWithM,
readMarkdown, Inline(Link), Pandoc)
main = getArgs >>= mapM readFile >>= mapM_ analyzePage
analyzePage x = processWithM printLinks (readMarkdown defaultParserState x)
printLinks (Link _ (x, _)) = putStrLn x >> return undefined
printLinks x   = return x

So now I can take `find . -name "*.page"`, pass the 100 or so Markdown
files in my wiki as arguments, and add the thousand or so external
links to the archiver queue (eg. `find . -name "*.page" | xargs
runhaskell link-extractor.hs >> ~/.urls.txt`); they will eventually be
archived/backed up and when combined with a tool like link-checker
means that there never need be any broken links since one can either
find a live link or use the archived version.

General comments: I've used archiver for a number of weeks now. It has
never caught up with my Firefox-generated backlog since WebCite seems
to have IP-based throttling so you can't request more often than once
per 20 seconds, according to my experiments, so I removed the hinotify
'watch file' functionality. It may be I was too hasty in removing it.

* http://en.wikipedia.org/wiki/WebCite
** http://en.wikipedia.org/wiki/Internet_Archive
*** There are sporadic exceptions from somewhere in the network or
HTTP libraries, I think
 http://linkchecker.sourceforge.net/

-- 
gwern
http://www.gwern.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell and a complete mail client lib?

2010-10-27 Thread Gwern Branwen
2010/10/27 Don Stewart :
> gue.schmidt:
>> Hi all,
>>
>> do we Haskellers have a complete Mail client library?
>
> As always, look on Hackage:
>
>    
> http://www.google.com/search?hl=en&as_sitesearch=hackage.haskell.org/package&as_q=email

Besides the tagged packages, there are a few other places one could
look if one searched the package listings carefully:

- http://hackage.haskell.org/package/HaskellNet
- http://hackage.haskell.org/package/postmaster
- http://hackage.haskell.org/package/pop3-client

Are any of these *complete*? Dunno. But I suspect you do not actually
need to do everything one could possibly do with email.

-- 
gwern
http://www.gwern.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] "back doors" into the IO monad

2010-10-24 Thread Gwern Branwen
On Sun, Oct 24, 2010 at 10:22 AM, Nicolas Pouillard
 wrote:
> On Sun, 24 Oct 2010 00:28:37 +0200, Manlio Perillo  
> wrote:
>> Hi.
>>
>> What are the available methods to execute IO actions from pure code?
>>
>> I know only unsafePerformIO and foreign import (to call a non pure
>> foreign function).
>
> unsafeCoerce is a back door for almost everything.
>

The mueval tests also include this fun example: 'runST (unsafeIOToST
(readFile "/etc/passwd"))'

-- 
gwern
http://www.gwern.net/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Haskell web development entries on the Wiki

2010-10-02 Thread Gwern Branwen
On Sat, Oct 2, 2010 at 4:13 PM, Michael Snoyman  wrote:
> I understand the advantages to splitting into multiple pages, but on
> the other hand it *does* make it more difficult to locate information.
> My guess is a good search function on the wiki will make that point
> moot. Overall, looks like you've done a great job, thanks! A few minor
> comments:
>
> * Should we rename HAppS to Happstack everywhere?

I think we should. No one is using the old HAppS code, so references
are just misleading.

--
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell Platform, Hackage and Cabal : The 2nd Year : Status Report

2010-10-01 Thread Gwern Branwen
On Fri, Oct 1, 2010 at 5:00 PM, Matthias Kilian  wrote:
> On Fri, Oct 01, 2010 at 09:29:32PM +0100, Malcolm Wallace wrote:
>> >The slides are here:
>> >
>> >   
>> > http://donsbot.wordpress.com/2010/10/01/hackage-cabal-and-the-haskell-platform-the-second-year/
>>
>> And the video is here:
>>     http://www.vimeo.com/15462768
>
> And is there any way to just *download* the video? For people not
> using adobe flash?

I believe Vimeo lets logged in users download the video.

For example, when I visit the link I see:
"*   640x360, 496.1MB
* Uploaded Fri October 01, 2010
* Download this video"

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Haskell at bettercodes.org

2010-09-22 Thread Gwern Branwen
On Wed, Sep 22, 2010 at 11:15 AM, David Sankel  wrote:

> I can understand why it would be slightly better for any website to not
> require JavaScript clients since it becomes a bit more accessible. I'm
> confused though about why being a "professional developer" site would make
> this feature even more important. Care to expand on that?
> Thanks,
> David

I would guess it's because developers are much more likely to be using
all manner of weird & wonderful methods of access, like a text browser
(elinks) from a command-line over a packet-radio link to the
sub-Saharan bush, as they try to develop a script to download the site
and compile everything into Brainfuck. Or something.

A 'normal' person, on the other hand, wouldn't know a
non-Safari/Firefox/IE/Chrome browser if it smacked them upside the
head.

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Changing my Profile

2010-08-24 Thread Gwern Branwen
On Tue, Aug 24, 2010 at 2:48 AM, David Virebayre
 wrote:
> 2010/8/23 Christopher Done :
>
>> Any suggestions would be appreciated.
>
> Isn't there the possibility to mute a thread in gmail ? You need to
> activate keyboard shortcuts, then "?" gives you a list of keys. m
> seems to be used to mute a thread, but I didn't try it so I don't know
> what it does exactly.
>
> David.

Muting applies a 'mute' label and removes any future emails from your
inbox. However, it doesn't change the read/unread status.

If I were to try to tackle this problem in Gmail, I think what I would
do is try to create a filter which makes only emails sent to both
gwe...@gmail.com and haskell-cafe@haskell.org, say, and have the
filter remove from inbox & mark read matching emails. So in theory I'd
only see the one copy sent by haskell.org. (If one can't directly
match on being sent to 2 addresses, I'm sure there's some more
indirect approach using labels and multiple filters.)

There's also 1 or 2 mailman options which do something similar with
suppressing duplicates.

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: The site has been exploited (again)

2010-07-12 Thread Gwern Branwen
On Sun, Jul 11, 2010 at 2:28 PM, Mike Dillon  wrote:
> begin Mike Dillon quotation:
>> Being that there is only one active admin on the Haskell.org wiki
>> (User:Ashley Y), I believe the fact that this page is editable by any
>> user is a policy decision to allow the community to contribute. The
>> page could be protected, but then only two administrators could edit it
>> (assuming John Peterson decided to become active again after two years
>> of not working on the wiki):
>>
>>     http://www.haskell.org/haskellwiki/?title=Special%3AListusers&group=sysop
>>
>> As for whether or not moving this particular wiki to a Haskell-based
>> solution would be a good idea, I don't see it being a win. I don't know
>> of any Haskell-based wikis that support MediaWiki syntax, so the effort
>> would involve converting all the existing content to some other format.
>> Being that MediaWiki's syntax is the most widespread wiki syntax at the
>> moment, I don't see how that would do anything but make it harder for
>> people to contribute.
>
> One more thing. On a wiki with active administrators, this user would
> have been blocked. That hasn't happened. The last block was in August
> 2009:
>
>    http://www.haskell.org/haskellwiki/?title=Special%3ALog&type=block
>
> If there is not someone regularly watching the wiki at all times, it
> would probably be prudent to protect some of the higher profile pages
> once there are more admins able to edit them.
>
> -md

Ashley has made me admin; I've spent the last 1.5 hours deleting all
the vandalism and indef blocking the accounts. I have Recent Changes
in my RSS reader, so hopefully in the future there will be no greater
than 24 hours delay before vandalism is dealt with. A MW upgrade will
also help (eg. currently checkuser* seems to be unavailable).

* http://www.mediawiki.org/wiki/Extension:CheckUser

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] HaskellWiki and Wikipedia

2010-06-19 Thread Gwern Branwen
On Sat, Jun 19, 2010 at 2:45 PM, Mike Dillon  wrote:
> Actually, it looks like MediaWiki:Newarticletext probably needs to be
> edited as well since that's what you see when you click through a red
> link. The others are for the top text after a search using "Go" and
> "Search" respectively.
>
> Unfortunately, this MediaWiki install doesn't appear to have interwiki
> links enabled; either that or the default "wikipedia:" interwiki
> doesn't work in this version or configuration. It's also horribly
> ancient, so it's hard to find docs on what is actually supported in the
> installed version since most docs out there reflect at least some of the
> changes that have happened in the software in the last five years.
>
> -md

Interwiki link do work, however, the interwiki map seems to be
extremely old. For example, an interwiki to Ward's Wiki (Meatball),
one of the oldest interwikis around, will work:
http://haskell.org/haskellwiki/?title=User%3AGwern&diff=35010&oldid=11424

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Language Shootout reverse-complement benchmark

2010-06-01 Thread Gwern Branwen
On Tue, Jun 1, 2010 at 10:25 AM, David Leimbach  wrote:
> I'm still trying to figure out what the point of the shootout really is.  If
> there's no dedicated folks working with a language there, trying to make
> things run faster, a language will come out looking inefficient potentially.
>  There's a lot of compile flags and optimizations that can make a difference
> in probably all of the languages listed on that page.

'Out of the crooked timber of humanity, no straight thing was ever made.'

> I guess all you can get from the shootout is a sense of what a particular
> language or set of tools is capable of in the hands of the programmers who
> submit implementations.  It doesn't really give you a concrete idea as to
> how to evaluate a programming language.
> It does still seem kind of fun for some reason though :-)
> Dave

The Shootout has a number of valuable purposes:

1) Concrete evidence that language X *can*, somehow, be as fast as language Y
2) Public examples of techniques to do #1, again concrete
3) Exposes where libraries/compilers can do better (this has happened
many times with GHC and Haskell libraries)
4) Motivates people to work on creating/fixing #2 and #3

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How efficient is read?

2010-05-11 Thread Gwern Branwen
On Tue, May 11, 2010 at 12:16 AM, Tom Hawkins  wrote:
>>
>> The tarball was missing its Rules.hs; as it happens, GHC has a module
>> named Rules.hs as well, hence the confusing error. I've uploaded a
>> fresh one that should work.
>
> Thanks.  This builds and installs fine.
>
> But I think there is something wrong with the generated parser.  It
> doesn't look for (..) groupings.  For example:
>
> data Something = Something Int (Maybe String)
>  deriving Show {-! derive : Parse !-}
>
> There is nothing in the generated parser to look for parens around the
> Maybe in case it is a (Just string).
>
> Am I missing something?

I don't know. If you could check whether the original Drift has that
error as well, then I suspect Drift's author, Meachem, would be
interested to know. (I only maintain drift-cabalized as a packaging
fork; I tried not to change any actual functionality.)

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How efficient is read?

2010-05-10 Thread Gwern Branwen
On Mon, May 10, 2010 at 4:50 PM, Tom Hawkins  wrote:
>> In fact, if you just want
>> Read-like functionality for a set of Haskell datatypes, use polyparse: the
>> DrIFT tool can derive polyparse's Text.Parse class (the equivalent of Read)
>> for you, so you do not even need to write the parser yourself!
>
> Cabal install DrIFT-cabalized complains.  What is the module "Rules"?
> I've never seen it before.
>
> Is there a quick fix?  I didn't see a "build-depends" line in my
> ~/.cabal/config file.
>
>
>
> e0082...@e0082888-laptop:~$ cabal install DrIFT-cabalized
> Resolving dependencies...
> Configuring DrIFT-cabalized-2.2.3.1...
> Preprocessing executables for DrIFT-cabalized-2.2.3.1...
> Building DrIFT-cabalized-2.2.3.1...
>
> src/DrIFT.hs:19:17:
>    Could not find module `Rules':
>      It is a member of the hidden package `ghc-6.12.2'.
>      Perhaps you need to add `ghc' to the build-depends in your .cabal file.
>      Use -v to see a list of the files searched for.
> cabal: Error: some packages failed to install:
> DrIFT-cabalized-2.2.3.1 failed during the building phase. The exception was:
> ExitFailure 1

The tarball was missing its Rules.hs; as it happens, GHC has a module
named Rules.hs as well, hence the confusing error. I've uploaded a
fresh one that should work.

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Haskell and scripting

2010-05-05 Thread Gwern Branwen
On Wed, May 5, 2010 at 4:29 PM, Limestraël  wrote:
> Yes, the xmonad approach is very neat, but I see 2 major (IMO) drawbacks to
> it:
> 1) The end-user has to have GHC, and all the necessary libraries to compile
> the configuration
> 2) A scripting language should be simple and QUICK to learn : Haskell is
> clean, powerful but its learning takes time

For basic customization, many XMonad users (judging by questions on
#xmonad) have little to no Haskell experience and get by. Further,
it's easier to step down the power than to increase it; because we use
Haskell, it's possible to have simpler configuration options like
xmonad-light*

* http://braincrater.wordpress.com/2008/08/28/announcing-xmonad-light/
isn't a very good explanation of xmonad-light, but I don't know of any
others

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell and scripting

2010-05-03 Thread Gwern Branwen
On Mon, May 3, 2010 at 5:47 PM, Kyle Murphy  wrote:
> That's also the approach Yi uses. I'm fairly certain there's a library on
> hackage that makes writing up programs in that style fairly trivial,

http://hackage.haskell.org/package/dyre

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Typing Haskell in Haskell

2010-05-01 Thread Gwern Branwen
On Sat, May 1, 2010 at 10:05 AM, Aaron Gray
 wrote:
> Hi,
> I am relatively new to Haskell. I am attempting to get "Typing Haskell in
> Haskell" to work on HUGS or GHC.
>    http://web.cecs.pdx.edu/~mpj/thih/
> I am getting an error on loading SourcePrelude :-
>    Hugs> :l SourcePrelude
>    ERROR ".\PPrint.hs" - Can't find imported module "Pretty"
> And I cannot find a Pretty module, the module and "Language.Haskell.Pretty"
> does not seem to be what is required.
> Any help welcome,
> Aaron

I strongly suggest you only bother with GHC and not try Hugs. As far
as THIH, I cabalized and uploaded it a while ago:
http://hackage.haskell.org/package/thih

You should have better luck with that.

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Downloading Haskell repos from GitHub

2010-04-30 Thread Gwern Branwen
On Fri, Apr 30, 2010 at 11:51 AM, Jesper Louis Andersen
 wrote:
> On Fri, Apr 30, 2010 at 5:38 PM, Gwern Branwen  wrote:
>> Nothing in http://develop.github.com/ seems especially useful for
>> grabbing the git:// URLs of all repos by language - just by user.
>>
>> The only real list of repos by language seems to be gotten at via
>> http://github.com/languages/Haskell/updated or
>> http://github.com/languages/Haskell/created . (You might think
>> http://github.com/languages/Haskell would be good, but no, it's just a
>> few random repos by interest and not a full listing.)
>
> Github has a REST API for accessing data. Unfortunately it can't give
> you the wanted
> breakdown, but I would ask them for it. It is much simpler for you,

You mean ask for a new feature? (Just a one-time list is no good since
I intend to repeat it regularly to pick up new repos, just like with
patch-tag.)

> and it does not put an extra strain on their servers due to the
> scraping.

Well, it'd only be about 2000 HTTP hits. (98 + (20 * 98)). The
downloading of the repos would probably reduce that demand to
insignificance, especially the first time around when most of the
repos would need to be downloaded.

> Usually, the github guys are helpful when you have a
> question.

Any suggested method besides the obvious http://github.com/contact ?

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Downloading Haskell repos from GitHub

2010-04-30 Thread Gwern Branwen
Along the lines of
http://blog.patch-tag.com/2010/03/13/mirroring-patch-tag/ for
downloading all patch-tag.com repositories, I've begun to wonder how
to download all Github repositories since more and more people seem to
be using it.

Nothing in http://develop.github.com/ seems especially useful for
grabbing the git:// URLs of all repos by language - just by user.

The only real list of repos by language seems to be gotten at via
http://github.com/languages/Haskell/updated or
http://github.com/languages/Haskell/created . (You might think
http://github.com/languages/Haskell would be good, but no, it's just a
few random repos by interest and not a full listing.)

I looked at the HTML, and it looks possible to use tagsoup to get all
98 pages and then parse the entries to get the HTTP URLs of the repos,
and then turn *that* into git:// URLs suitable for shelling out to
'git clone', but I can't help but wonder if maybe there's a better
approach someone more familiar with Github would know.

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The instability of Haskell libraries

2010-04-23 Thread Gwern Branwen
On Fri, Apr 23, 2010 at 7:17 PM, Ivan Lazar Miljenovic
 wrote:
> Keith Sheppard  writes:
>> Set up a server to poll the "Source-Repository head" of every hackage
>> package that includes one in it's cabal file, then rerun the build any
>> time a change is detected. This may be a good excuse to implement a
>> pluggable continuous integration server in haskell too along the lines
>> of what Hudson is for java... maybe an idea for the next GSoC
>
> Several problems with this:
>
> 1) Is this going to support every VCS under the sun?

We only need to support 3 or 4 to get 99% of the stuff on Hackage that
lives in a VCS at all.

> 2) Not all head repositories are kept stable/buildable at all times.

Perfect, meet better. Wait, no no - aw goddammit Perfect! Why do you
do this every single time? *You* get to mop the floor this time.

> 3) I can see this getting expensive wrt space and network usage.

Not really. I do much the same thing locally. Most repos hardly ever change.

My own local repos - which includes all of patch-tag, a few GHCs, some
intermediate builds, and whatnot - is about 4.5G. By my calculations*
that's about 25¢ of hard-drive space.

* http://forre.st/storage#sata

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] problem with cabal on snow leopard

2010-04-17 Thread Gwern Branwen
On Sat, Apr 17, 2010 at 5:30 PM, Carter Schonwald
 wrote:
> Hello all,
> I can't seem to find it documented anywhere as to the default directories
> that cabal puts its information in  (its certainly not in ~/.cabal ),  as
> I'm finding that even when I try to do a "reinstall" of the haskell
> platform, cabal thinks that all the libraries i removed are still there. how
> can i fix this?
> thanks
> -Carter

~/.cabal doesn't store regular Haskell stuff; if you try one of the
few uncabalized autotools-based Haskell packages, you'd see your other
Cabal-based libs & progs picking it up. Cabal installs stuff and
registers it with GHC, which maintains the master database of what's
installed; eg. 'ghc-pkg list'. This is usually kept in ~/.ghc:
find ~/.ghc/ :
.ghc/
.ghc/ghci_history
.ghc/i386-linux-6.10.4
.ghc/i386-linux-6.10.4/package.conf

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] What is the consensus about -fwarn-unused-do-bind ?

2010-04-09 Thread Gwern Branwen
On Fri, Apr 9, 2010 at 10:20 AM, Neil Brown  wrote:
> Ivan Lazar Miljenovic wrote:
>>
>> As of 6.12.1, the new -fwarn-unused-do-bind warning is activated with
>> -Wall.  This is based off a bug report by Neil Mitchell:
>> http://hackage.haskell.org/trac/ghc/ticket/3263 .
>>
>> However, does it make sense for this to be turned on with -Wall?  For
>> starters, why should this warning apply only to do blocks and not to
>> explicit usage of >>, etc.?  That is, the following code (as specified
>> in the above bug report) generates an error:
>>
>>   do doesFileExist "foo"
>>      return 1
>>
>> yet this doesn't:
>>
>>    doesFileExist "foo" >> return 1
>>
>
> The comments in that bug report actually mention "My patch does not warn on
> uses of >>, only in do-notation, where the situation is more clear cut".  I
> take >> to be an explicit sign that the user wants to ignore the result of
> the first action, whereas in do-notation it may be an accident.  So I think
> it was the right decision.

Relevant link: 
http://neilmitchell.blogspot.com/2008/12/mapm-mapm-and-monadic-statements.html

>>  2. Use some function of type "(Monad m) => m a -> m ()" instead of doing
>>     "_ <-".
>>
>>  3. Duplicate the parser combinators in question so that I have one
>>     version that returns a value and another that does the main parser
>>     and then returns (); then use this second combinator in do blocks
>>     where I don't care about the returned value.
>>
>>  4. Put "-fno-warn-unused-do-bind" in the .cabal file.
>>
>> The first two options don't appeal to me as being excessive usage of
>> boilerplate; the third involves too much code duplication.  However, I
>> am loath to just go and disable a warning globally.
>>
>
> I'd be tempted by number two, but I it's more typing to write "ignore $"
> than "_ <-", so maybe 1 is the best option after all.  I've frequently
> encountered the annoyance of monadic return values -- but to satisfy type
> signatures rather than avoid this warning.  For example, I have a CHP
> parallel operator: (<||>) :: CHP a -> CHP b -> CHP (a,b) and a function
> writeChannel :: Chanout a -> a -> CHP ().  But if you try to write a
> function like:

It's actually going to be named 'void':
http://hackage.haskell.org/trac/ghc/ticket/3292

I don't think it's made it into a stable release yet.

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Simple game: a monad for each player

2010-04-08 Thread Gwern Branwen
On Thu, Apr 8, 2010 at 4:08 PM, Yves Parès  wrote:
>
> Hello Cafe,
>
> I have a question about program design.
> Let's say I have a simple sequential game (a TicTacToe for instance, but
> with more than 2 players).
> I have a Player datatype which is like:
>
> data Player m = Player {
>    plName :: String,  -- unique for each player
>    plTurn :: GameGrid -> m Move  -- called whenever the player must play
> }
>
> As you may guess, the 'm' type variable is intended to be a Monad.
> The goal is that every player has his own monad. For instance :
> - a human player needs to interact with the program, so its monad would be
> IO, or an instance of MonadIO.
> - a network player, which transparently sends the game state and receives
> moves through network, must also have access to IO to play.
> - an AI doesn't need to interact with the outside of the program, so its
> monad can be the one we want (e.g. Identity).
>
> First, do you think it is a good way to design the program?
> I want the game to be totally independent of the players who are currently
> playing. They can be humans, AIs, AIs and network players and humans, and so
> on.
>
> But when running the game, the program cannot "switch" from a player's monad
> to another.
> If we want every player to run in his own monad, I think we have to stack
> every players' monad, and lift their actions each time they have to play.
> This is not a problem, the sole condition now is that every player has type:
> (Monad m, MonadTrans m) => Player m.
>
> But I think it's a little bit of overkill, and it may be a little bit
> complicated to implement such a thing.
> What I try to avoid is having every player running in IO monad.
>
> Do you have any suggestion?
>
> -
> Yves Parès

Your desires remind me of the MonadPrompt package
, which IIRC, has been
used in some game demos to provide abstraction from IO/test
harness/pure AI etc.

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] [OT?] Haskell-inspired functions for BASH

2010-04-06 Thread Gwern Branwen
On Tue, Apr 6, 2010 at 11:17 AM, Stephen Tetley
 wrote:
> On 6 April 2010 15:09, Mario Blažević  wrote:
>
>>        A question of my own: is there any written design (an academic paper
>> would be perfect) of a functional shell language?
>
>
> Olin Shivers has written a detailed paper on Scsh.
>
> ftp://www-swiss.ai.mit.edu/pub/su/scsh/scsh-paper.ps
>
> The link might be down permanently (it is for me at the moment), maybe
> the paper is on Citeseer or similar. There is also the Scsh manual.
>
> Best wishes
>
> Stephen

The Scsh manual is worth reading just for the introductory material.

Part of the problem is that both Clean and Scheme have relatively easy
and powerful 'eval' ability. (Esther exploits the interesting feature
of Clean that lets you serialize functions to disk.)

Haskell doesn't, so much. The GHC API isn't too great to work with
here; it's hard enough to evaluate straight Haskell fragments, and to
serve as a shell, you really need new syntax; for example, you want
literals for program names. (Who would use a shell which forces you to
write 'run "ghci" ["foo.lhs"]', instead of 'ghci foo.lhs'?) But many
filenames break in Haskell; 'ssh-agent', 'g++-4.4', 'bf_tar', etc.

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hackage accounts and real names

2010-04-05 Thread Gwern Branwen
On Sun, Apr 4, 2010 at 5:28 PM, David House  wrote:
> Hi,
>
> An issue came up on #haskell recently with Hackage accounts requiring
> real names. The person in question (who didn't send this email as he's
> wishing to remain anonymous) applied for a Hackage account and was
> turned down, as he refused to offer his real name for the username.
>
> Those of us in the conversation thought this a bit of an odd policy,
> and were wondering where this came from. It also emerged that a couple
> of other people had been held back from getting Hackage accounts
> because of this reason.

It must've been put in place in the past year or two; I've never made
any bones about using a pseudonym, and I had no trouble getting a
Hackage account back when it was starting up.

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] [OT?] Haskell-inspired functions for BASH

2010-04-01 Thread Gwern Branwen
On Thu, Apr 1, 2010 at 11:13 AM, Jeremy Shaw  wrote:
> fps is what we now call bytestring. Alas, hsplugins is dead. hsplugins is
> useful, but needs to be rewritten for modern GHC :(
> - jeremy

I never looked into hsplugins too carefully. Did it offer anything
that Hint doesn't now offer?

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: Salvia-1.0.0

2010-03-23 Thread Gwern Branwen
On Tue, Mar 23, 2010 at 9:27 AM, Bas van Dijk  wrote:
> On Tue, Mar 23, 2010 at 2:13 PM, Sebastiaan Visser  wrote:
>> Nice! This is certainly worth it.
>
> I'm glad you like it.
>
> Sebastiaan, I made the same mistake as threadmanager does: I forgot to
> block before installing the deleteMyPid exception handler in the
> forked thread. I added a new patch that adds the necessary block and
> unblock: http://bifunctor.homelinux.net/~bas/salvia/
>
> BTW What's the git equivalent of 'darcs send -o ' which
> saves the patches to ? I would rather send my patches as
> email attachements instead of copying my repository to my webserver.
> (Note this is the first time I used git)

I use ' git format-patch origin'.

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Prelude.undefined

2010-03-03 Thread Gwern Branwen
On Wed, Mar 3, 2010 at 10:56 AM, Tom Hawkins  wrote:
> On Wed, Mar 3, 2010 at 7:24 AM, Alexander Dunlap
>  wrote:
>> On Tue, Mar 2, 2010 at 9:06 PM, Tom Hawkins  wrote:
>>> How do I track down an reference to an undefined value?  My program
>>> must not be using a library correctly because the program makes no
>>> direct use of 'undefined'.  Running with +RTS -xc yields:
>>>
>>
>> While the debugger, etc., are very useful tools, I find that often the
>> easiest way to track down this sort of bug is to test your code
>> function-by-function.
>
> The debugger was not that helpful, so I may have to resort to this.
>
> Is there any work being done to improve reporting for these type of
> errors?  It seems to be a fairly common problem.

You try the Interlude? http://hackage.haskell.org/package/interlude

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Has anybody translated Douglas Hofstadter's Scientific American articles introducting Scheme to a general audience into Haskell?

2010-03-02 Thread Gwern Branwen
On Tue, Mar 2, 2010 at 1:04 AM, Benjamin L. Russell
 wrote:
> There is an interesting, if somewhat dated, suggestion on "Lambda the
> Ultimate" (see http://lambda-the-ultimate.org/node/1748) that "someone
> translate Doug Hofstadter's Scientific American columns introducing
> Scheme to a general audience into Haskell."
>
> (I came across this link while adding full titles and links to the
> HaskellWiki "Books and tutorials" page (see
> http://www.haskell.org/haskellwiki/Books_and_tutorials), where I clicked
> on the link to "Tutorials" (see
> http://www.haskell.org/haskellwiki/Tutorials), which contained a link to
> a "Haskell vs. Scheme" (see http://www.reddit.com/r/programming/tb/nq1k)
> article, which described the post containing the suggestion.)
>
> According to a comment by Ehud Lamm (see
> http://lambda-the-ultimate.org/node/1748#comment-21292) on the above
> post, the columns are in Hoftstadter's book _Metamagical Themas:
> Questing For The Essence Of Mind And Pattern_ [1] (see
> http://www.amazon.com/Metamagical-Themas-Questing-Essence-Pattern/dp/0465045669).
>
> Has anybody translated Hofstadter's articles from Scheme into Haskell?
>
> -- Benjamin L. Russell

I have scans of the column and have meant to translate them; but you
know how it is...

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Function to detect duplicates

2010-02-24 Thread Gwern Branwen
2010/2/23 Jonas Almström Duregård :
> Hi Rafael,
>
> I assume you will perform this operation on some very large lists, or
> performance would not be an issue. Have you tested if your optimized
> version is better than your initial one?
>
> You should compare your implementation against something like this:
>
> import qualified Data.Set as Set
> noneRepeated :: (Ord a) => [a] -> Bool
> noneRepeated = accum Set.empty where
>  accum _ [] = True
>  accum s (x:xs)
>    | Set.member x s = False
>    | otherwise      = accum (Set.insert x s) xs
>
> Also there is some discussion about the nub function that relates to
> this topic, e.g. http://buffered.io/2008/07/28/a-better-nub/.
>
> /Jonas

Or better yet, 
http://www.haskell.org/pipermail/libraries/2008-October/010778.html
Much more thorough and practical w/r/t to actually getting faster nubs
in the libraries.

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] What happened in Ohloh?

2010-02-19 Thread Gwern Branwen
On Fri, Feb 19, 2010 at 5:20 PM, Paul Johnson  wrote:
> If you go to
> http://www.ohloh.net/languages/compare?l0=haskell&measure=projects and look
> at the number (not percentage) of Haskell projects you see it rise
> exponentially until the start of 2008 and then suddenly drop away.  Does
> anyone know what happened?  Assuming this is just an artefact because they
> aren't scanning Haskell project hosts, can we get them to fix it?

I believe in early 2008 Don Stewart was on a kick where he used tailor
to convert Darcs repos of Haskell projects to Git repos (which Ohloh
understands), and he's stopped doing that.

The fix would involve making their software understand darcs; their
response hasn't been too enthusiastic or helpful (basically, 'if you
guys do all the work and meet our idiosyncratic standards, maybe we'll
use it'): http://www.ohloh.net/forums/3491/topics/1138?page=2

> I'd like to use this kind of graph at work as evidence that Haskell is on a
> growth trajectory.
>
> Paul.

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell and the Job Market, e.g. with Google

2010-02-11 Thread Gwern Branwen
On Thu, Feb 11, 2010 at 11:49 AM, Hans van Thiel  wrote:
> Hello,
> Somewhat in response to the original post about Haskell engineers I, II
> and III. This confirms the remark that Haskell experience is now being
> appreciated, though not (yet) used (very much). Steven Grant, recruiter
> from Google, asked me to bring to his attention anyone who might be
> suitable, so that's what I'm doing.
>
> 
> We are currently aggressively recruiting for a large number of engineers
> in EMEA. I spotted your extensive open source experience and was
> particularily interested to see you have worked with Haskell. I am not
> looking for a Haskell developer but more interested in people that have
> worked in exotic languages such as Haskell or Erlang or Scheme.
>
> The roles we have are heavily open sourced based and will be mainly
> working with Python, C, Linux, shell etc and are based in Dublin, London
> or Zurich.
>
> If you have any interest in discussing these further, drop me an email
> to stevengr...@google.com and we can discuss.
> 
>
> >From a second email:
> 
> The job specs are below.
>
> http://www.google.ie/support/jobs/bin/answer.py?answer=34884
> http://www.google.ie/support/jobs/bin/answer.py?answer=34883
>
> The roles are within a very specialist team within Google.
> They are a hybrid type role and are responsible for making our
> products reliable scalable and more efficient.
> 
>
> Get in touch with Steven:
>
> Steven Grant
>
> European IT Staffing
> Phone: +353 1 543 5083
> Google Ireland Ltd., Barrow Street, Dublin 4, Ireland
> Registered in Dublin, Ireland
> Registration Number: 368047
>
> I think this is interesting even to those who are not looking for a job
> right now, since it shows the current mind-set regarding Haskell, at a
> major and leading IT company.
>
> Best Regards,
>
> Hans van Thiel

I would be far from the first to remark that the 'Python Paradox'
(http://www.paulgraham.com/pypar.html) has moved on and become the
Scala/Haskell Paradox.

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Links to darcs.haskel.org in the haskellwiki

2010-02-08 Thread Gwern Branwen
On Mon, Feb 8, 2010 at 5:35 PM, Henning Thielemann
 wrote:
> Ketil Malde schrieb:
>>
>> "Henk-Jan van Tuyl"  writes:
>>
>>
>>>
>>> There are a lot of links in the haskellwiki that point to projects at
>>> darcs.haskel.org; I hope that anyone who moves a project, looks the
>>> links  up and updates them. An example of a page with several obsolete
>>> links is
>>>
>>
>> I check my own pages once in a while with Google webmaster tools, which
>> tells me about these things (and provides other useful information as
>> well).  Perhaps this is useful for the Haskell wiki as well?
>>
>
> Bulk updates in Wikis are not very funny. I have also searched for links to
> my darcs.haskell.org repositories in HaskellWiki and I hope I have updated
> them all, which is very cumbersome. It would be cool if there would be a way
> to access the Wiki contents like a file system, such that I can use 'grep'
> and friends for such tasks.

http://en.wikipedia.org/wiki/Wikipedia:WikipediaFS

It was working when I last tried it a year or 3 ago; no idea whether
it still does or would work with Hawiki. Also, it's 'on demand'
loading.

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Anyone up for Google SoC 2010?

2010-02-05 Thread Gwern Branwen
On Fri, Feb 5, 2010 at 3:38 PM, Niklas Broberg  wrote:
> I'm at a loss as to what criteria is actually used to judge success
> here. It seems to me a bit like the eternal discussion between "basic
> research" and "applied research". Just because something
> (research/library/project) doesn't have an immediate, palpable impact
> and/or delivers a visible tool, that certainly doesn't imply that it
> doesn't have merit or won't have as profound an impact on the domain,
> if more diffuse than a tool (or other palpable deliverable) would.
>
> /Niklas

There may be an eternal discussion on it, but it seems pretty clear to
me which side SoC comes down on: http://code.google.com/soc/

"Through Google Summer of Code, accepted student applicants are paired
with a mentor or mentors from the participating projects, thus gaining
exposure to real-world software development scenarios and the
opportunity for employment in areas related to their academic
pursuits. In turn, the participating projects are able to more easily
identify and bring in new developers. Best of all, more source code is
created and released for the use and benefit of all."

or http://socghop.appspot.com/document/show/program/google/gsoc2009/faqs#goals

# Google Summer of Code has several goals:

* Get more open source code created and released for the benefit of all
* Inspire young developers to begin participating in open source development
* Help open source projects identify and bring in new developers
and committers
* Provide students the opportunity to do work related to their
academic pursuits during the summer (think "flip bits, not burgers")
* Give students more exposure to real-world software development
scenarios (e.g., distributed development, software licensing
questions, mailing-list etiquette)

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Anyone up for Google SoC 2010?

2010-02-05 Thread Gwern Branwen
On Fri, Feb 5, 2010 at 6:20 AM, Sittampalam, Ganesh
 wrote:
> Gwern Branwen wrote:
>> On Wed, Feb 3, 2010 at 8:14 PM, Henk-Jan van Tuyl 
>> wrote:
>>> On Wed, 03 Feb 2010 23:34:34 +0100, Neil Mitchell
>>> 
>>> wrote:
>>>
>>>> Hi Gwern,
>>>>
>>>> Please update: "haskell-src-exts -> haskell-src" **Unknown**
>>>>
>>>> This project was an unqualified success.  haskell-src-exts is now
>>>> one
>>>> of the most commonly used Haskell libraries, achieved the goals in
>>>> the project proposal, and is an essential piece of Haskell
>>>> infrastructure.
>>>
>>> You can see this using Roel van Dijk's reversed dependencies
>>> overview [1]: 23 direct and 57 indirect dependencies on
>>> haskell-src-exts-1.8.0
>>>
>>> Regards,
>>> Henk-Jan van Tuyl
>>
>> And how many of those used haskell-src-exts *before* the SoC project?
>> And would have used it regardless? You can't point to a popular
>> project which got a SoC student, and say look at how popular it is -
>> obviously the SoC student was hugely successful.
>
> Regardless of that, is there any reason to disregard Neil's summary and not 
> update your page?
>
> Ganesh

I prefer to wait. haskell-src-exts was popular before, it was popular
after. The question is not whether the patches were applied, or
whether the mentor told Google it was successful, but whether it was
the best possible use of the SoC slot. If features do not get used,
then it wasn't a good SoC. If you know 3 or 4 uses of the new
haskell-src-exts features in (relatively) major applications like
hlint, then I'll concede the point and mark it a success.

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Anyone up for Google SoC 2010?

2010-02-04 Thread Gwern Branwen
On Wed, Feb 3, 2010 at 8:14 PM, Henk-Jan van Tuyl  wrote:
> On Wed, 03 Feb 2010 23:34:34 +0100, Neil Mitchell 
> wrote:
>
>> Hi Gwern,
>>
>> Please update: "haskell-src-exts -> haskell-src" **Unknown**
>>
>> This project was an unqualified success.  haskell-src-exts is now one
>> of the most commonly used Haskell libraries, achieved the goals in the
>> project proposal, and is an essential piece of Haskell infrastructure.
>
> You can see this using Roel van Dijk's reversed dependencies overview [1]:
> 23 direct and 57 indirect dependencies on haskell-src-exts-1.8.0
>
> Regards,
> Henk-Jan van Tuyl

And how many of those used haskell-src-exts *before* the SoC project?
And would have used it regardless? You can't point to a popular
project which got a SoC student, and say look at how popular it is -
obviously the SoC student was hugely successful.

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Anyone up for Google SoC 2010?

2010-02-02 Thread Gwern Branwen
On Tue, Feb 2, 2010 at 5:11 PM, Johan Tibell  wrote:
> On Tue, Feb 2, 2010 at 2:06 PM, Neil Mitchell  wrote:
>>
>> I'd also be happy to mentor. Where is the official place to collect
>> project ideas? We used trac previously, are we still using it or are
>> we now on Reddit?
>
> Is there a way to prune the reddit list? Some of the projects (like 'text')
> are already done. Also, voting doesn't work well for reddit as we're still
> seeing votes from last year.
> -- Johan

You can prune them personally with 'hide', and I suppose the subreddit
moderator can delete expired entries.

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Failure to load hmatric

2010-02-02 Thread Gwern Branwen
On Tue, Feb 2, 2010 at 1:59 PM,   wrote:
> OK, I'm working on matrix stuff in Haskell now (I've been trying to get
> the professor to approve that) and when I use cabal install to install
> hmatrix, it fails at HUnit with:
> ---
> Configuring HUnit-1.2.2.1...
> Preprocessing library HUnit-1.2.2.1...
> Preprocessing executables for HUnit-1.2.2.1...
> Building HUnit-1.2.2.1...
> [1 of 5] Compiling Test.HUnit.Terminal ( Test/HUnit/Terminal.hs,
> dist/build/Test/HUnit/Terminal.o )
> [2 of 5] Compiling Test.HUnit.Lang  ( Test/HUnit/Lang.hs,
> dist/build/Test/HUnit/Lang.o )
> [3 of 5] Compiling Test.HUnit.Base  ( Test/HUnit/Base.hs,
> dist/build/Test/HUnit/Base.o )
> [4 of 5] Compiling Test.HUnit.Text  ( Test/HUnit/Text.hs,
> dist/build/Test/HUnit/Text.o )
> [5 of 5] Compiling Test.HUnit       ( Test/HUnit.hs,
> dist/build/Test/HUnit.o )
> /usr/bin/ar: creating dist/build/libHSHUnit-1.2.2.1.a
>
> Test/HUnit/Lang.hs:22:1: lexical error at character 'i'
> cabal: Error: some packages failed to install:
> HUnit-1.2.2.1 failed during the building phase. The exception was:
> exit: ExitFailure 1
> 
>
> Short term question:  what the heck do I do with this?
>
> Long term question: how can I handle cabal failures of this type without
> bothering the list every time?
>
> Dave Barton
> University of Toronto

Well, the obvious thing to do is to look at the line causing the
error. The line and surrounding lines are:

---
-- Imports
-- ---

import Data.List (isPrefixOf)
21: #if defined(__GLASGOW_HASKELL__) || defined(__HUGS__)
import Data.Dynamic
import Control.Exception as E
#else
import System.IO.Error (ioeGetErrorString, try)
#endif
---

Line 12 is the first CPP directive in the file; GHC doesn't understand
CPP unless you tell it to. So one could look at the hunit.cabal and
try to figure out why CPP wasn't enabled, or one could add into the
first line of the file
'{-# LANGUAGE CPP #-}'
and work around it.

But you can't start if you don't know what the problem is.

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] HList darcs repo missing?

2010-01-25 Thread Gwern Branwen
On Mon, Jan 25, 2010 at 3:47 PM, Jake Wheat
 wrote:
> Hello all,
>
> I was looking for the HList darcs repo at:
>
> http://darcs.haskell.org/HList/
>
> but it seems to be missing. Has it been moved somewhere else?
>
> Thanks,
> Jake Wheat

It was there as of 15 September 2009 when I sent Oleg my last patch.
Maybe some of the server changes since messed around with it?

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Broken registration link on hackage trac

2010-01-18 Thread Gwern Branwen
On Mon, Jan 18, 2010 at 6:17 PM, Ian Lynagh  wrote:
> On Mon, Jan 18, 2010 at 07:35:31PM +, Andy Gimblett wrote:
>>
>> I want to register an account on hackage's trac instance, but the
>> "register an account" link on the start page:
>>
>> http://hackage.haskell.org/trac/hackage/wiki/WikiStart
>>
>> is broken.
>
> Fixed - thanks for the report.
>
>
> Thanks
> Ian

While we're fixing things, has anyone else noticed that the QuickCheck
mailing list seems to be broken?


-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] cabal install vacuum-cairo

2010-01-17 Thread Gwern Branwen
On Sun, Jan 17, 2010 at 9:55 AM, Ozgur Akgun  wrote:
> Cafe,
>
> I've been trying to install vacuum-cairo using cabal but I couldn't have it
> installed because of the missing packages cairo, svg and gtkcairo.
>
> What should I do to install vacuum-cairo?
>
> Thanks for any help in advance,

Those packages are provided by http://www.haskell.org/gtk2hs/

cabal-install didn't pull them in because they are too difficult to
cabalize & hence not on Hackage.

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Compilers

2010-01-16 Thread Gwern Branwen
On Sat, Nov 29, 2008 at 8:02 PM, John Meacham  wrote:
> On Sat, Nov 29, 2008 at 11:41:03PM +0100, Daniel Fischer wrote:
>> Great, nothing I don't already have, so download the source tarball, unpack
>> and
>> ./configure --prefix=$HOME
>> checking for a BSD-compatible install... /usr/bin/install -c
>> checking whether build environment is sane... yes
>> ... more configure output ...
>> checking for drift-ghc... no
>> configure: error:  DrIFT not found get it from
>> http://repetae.net/computer/haskell/DrIFT/
>>
>> Huh?
>> da...@linux:~/jhc/jhc-0.5.20080307> which DrIFT
>> /home/dafis/.cabal/bin/DrIFT
>> da...@linux:~/jhc/jhc-0.5.20080307> DrIFT --version
>> Version DrIFT-2.2.3
>
> Oh golly. I never put DrIFT on cabal, apparently whomever tried to
> cabalize it didn't include the ghc driver script, and also appeared to
> just drop the documentation from the package altogether. It is things
> like that that make it very hard to get behind cabal, why was DrIFT
> crippled just so it can be put on cabal? If cabal wasn't powerful enough
> to compile DrIFT, and we already had a perfectly good way of compiling
> it, why the need to shoehorn it in and cause this problem? sigh.
...
>        John

Thought I'd mention that
http://hackage.haskell.org/package/DrIFT-cabalized 2.2.3.1 includes a
drift-ghc.hs (compiles to /home/gwern/bin/bin/DrIFT-cabalized-ghc)
which is a clone of the drift-ghc.in shell script you allude to:

import Data.List (isInfixOf)
import System.Cmd (rawSystem)
import System.Environment (getArgs)
import System.Exit (ExitCode(ExitSuccess))
import Paths_DrIFT_cabalized  (getBinDir)

main :: IO ExitCode
main = do args <- getArgs
  case args of
(a:b:c:[]) -> conditional a b c
_ -> error "This is a driver script allowing DrIFT to be
used seamlessly with ghc.\n \
   \ in order to use it, pass '-pgmF drift-ghc -F'
to ghc when compiling your programs."

conditional ::  FilePath -> FilePath -> FilePath -> IO ExitCode
conditional orgnl inf outf = do prefix <- getBinDir
infile <- readFile inf
if "{-!" `isInfixOf` infile then do
putStrLn (prefix ++ "DriFT-cabalized " ++

   inf ++ " -o " ++ outf)

rawSystem inf ["-o", outf]
 else do writeFile outf ("{-# LINE 1
\"" ++ orgnl ++ " #-}")
 readFile inf >>= appendFile outf
 return ExitSuccess
{- GHC docs say: "-pgmF cmd
   Use cmd as the pre-processor (with -F only).
Use -pgmF cmd  to select the program to use as the preprocessor.
When invoked, the cmd pre-processor is given at least three arguments
on its command-line:
1. the first argument is the name of the original source file,
2. the second is the name of the file holding the input
3. third is the name of the file where cmd should write its output to." -}

John: I would appreciate you pointing out if I have made a mistake
anywhere in that and not actually replicated the functionality of the
shell script. (I think I have, but I didn't really understand what the
first echo was supposed to do and just copied its functionality.)

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Design question, HTML for GUIs?

2010-01-10 Thread Gwern Branwen
2010/1/10 Günther Schmidt :
> Hi everyone,
>
> as probably most people I find the GUI part of any application to be the
> hardest part.
>
> It just occurred to me that I *could* write my wxHaskell desktop application
> as a web app too.
>
> When the app starts, a haskell web server start listening on localhost port
> 8080 for example and I fire up a browser to page localhost:8080 without the
> user actually knowing too much about it.
>
> Is that a totally stupid idea?
> Which haskell web servers would make good candidates?

No; Happstack. See Gitit for an example - it is a wiki, but people use
it locally all the time, such as myself or Don Stewart.

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ghc -e

2010-01-06 Thread Gwern Branwen
On Wed, Jan 6, 2010 at 7:35 PM, Tony Morris  wrote:
> Gwern Branwen wrote:
>> On Wed, Jan 6, 2010 at 7:23 PM, Tony Morris  wrote:
>>
>>> ghc -e "import Control.Monad; forM [[1,2,3]] reverse"
>>>
>>
>> As of 6.10.2, the bug whereby the GHC API lets you use functions from
>> anywhere just by naming them (Java-style) has not been fixed:
>>
>> $ ghc -e "Control.Monad.forM [[1,2,3]] reverse"
>> package flags have changed, resetting and loading new packages...
>>
>> :1:25:
>>     Warning: Defaulting the following constraint(s) to type `Integer'
>>              `Num t' arising from the literal `3' at :1:25
>>     In the expression: 3
>>     In the expression: [1, 2, 3]
>>     In the first argument of `forM', namely `[[1, 2, 3]]'
>>
>> :1:25:
>>     Warning: Defaulting the following constraint(s) to type `Integer'
>>              `Num t' arising from the literal `3' at :1:25
>>     In the expression: 3
>>     In the expression: [1, 2, 3]
>>     In the first argument of `forM', namely `[[1, 2, 3]]'
>> [[3],[2],[1]]
>> it :: [[Integer]]
>> (0.01 secs, 1710984 bytes)
>>
>>
> I see the same on GHC 6.10.4.
> $ ghc -e "Control.Monad.forM [[1,2,3]] reverse"
> [[3],[2],[1]]
>
>
> What would it be fixed to? What is wrong with how it is?

Presumably one then have to use some sort of flag to ask for
Control.Monad specifically to be visible.

What's wrong with it is that this is not merely GHCi behavior, this is
universal GHC API behavior and wildly insecure:
http://hackage.haskell.org/trac/ghc/ticket/2452

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ghc -e

2010-01-06 Thread Gwern Branwen
On Wed, Jan 6, 2010 at 7:23 PM, Tony Morris  wrote:
> ghc -e "import Control.Monad; forM [[1,2,3]] reverse"

As of 6.10.2, the bug whereby the GHC API lets you use functions from
anywhere just by naming them (Java-style) has not been fixed:

$ ghc -e "Control.Monad.forM [[1,2,3]] reverse"
package flags have changed, resetting and loading new packages...

:1:25:
Warning: Defaulting the following constraint(s) to type `Integer'
 `Num t' arising from the literal `3' at :1:25
In the expression: 3
In the expression: [1, 2, 3]
In the first argument of `forM', namely `[[1, 2, 3]]'

:1:25:
Warning: Defaulting the following constraint(s) to type `Integer'
 `Num t' arising from the literal `3' at :1:25
In the expression: 3
In the expression: [1, 2, 3]
In the first argument of `forM', namely `[[1, 2, 3]]'
[[3],[2],[1]]
it :: [[Integer]]
(0.01 secs, 1710984 bytes)

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Memory-aware Haskell?

2009-12-25 Thread Gwern Branwen
On Fri, Dec 25, 2009 at 5:14 AM, Svein Ove Aas  wrote:
> On Thu, Dec 24, 2009 at 11:38 PM, Roman Cheplyaka  wrote:
>> So, let's think what we can do at runtime. Suppose RTS takes the parameter --
>> upper limit of consumed memory. When it sees that memory consumption is
>> close to upper bound, it can:
>>
>> 1. force garbage collection
>>
> This is already implemented. See the -M RTS option.

Correct me if I'm wrong - it's been a while since I tried to use the
-M option to deal with Gitit memory usage on darcs.net - but doesn't
-M just kill the program after it reaches a set RAM, and doesn't
trigger any GCs?

-- 
gwern
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


  1   2   3   >