[darcs-users] darcs patch: Data format and converter for "square" r... (and 4 more)
Max Battcher
me at worldmaker.net
Sat May 29 23:29:00 UTC 2010
A few brief, immediate responses:
On 05/29/2010 11:56 AM, Eric Kow wrote:
>> + repoOrder a b = compare (reponame a) (reponame b)
>
> This can be written as compare `on` reponame
>
> on :: (b -> b -> c) -> (a -> b) -> a -> a -> c Source
> (*) `on` f = \x y -> f x * f y.
>
> (The kind of thing one picks up through cultural osmosis)
Neat. That does seem useful. I figured there was probably a name for
that, but `on` probably wouldn't have occurred to me.
> Refactor Run.hs to use updated tabulateRepo
> -------------------------------------------
>> - case tabulate formatTimeResult res of
>> - [] -> return ()
>> - [(_,t)] -> echo_n $ TR.render id id id t
>> - _ -> error "Not expecting more than one table for a repo and its variants"
>> + let tables = repoTables benchmarks res
>> + if length tables == 1 then
>> + echo_n $ TR.render id id id $ tabulateRepo formatTimeResult (head tables)
>> + else error "Not expecting more than one table for a repo and its variants"
>
> Note that checking length and doing head is slightly less safe than just
> relying on pattern-matching with case (albeit perhaps more readable).
> It's unlikely that you'll break apart if length tables == 1 then foo
> (head tables), which is why I say "slightly"
If I do more Haskell I'll probably have to break myself of the head/tail
over-reliance. (Prior to Haskell I did spend a few months hacking in
Common Lisp where that pattern's so common there's a million names for
it...) Luckily for me the list comprehension over-reliance from Python
hacking seems to fit in reasonably well with Haskell. :)
> Also: do we never get the empty list?
I've got a feeling that it never happens. More than that, I'm pretty
sure that Run.hs itself is deprecated and never actually used, but I
wasn't sure enough to actually just go ahead and remove it. It seems to
me to be an old "main" function from back before darcs-benchmark started
using CmdArgs sub-commands, but I didn't take the time to do the
darcs-fu to double check that against repository history. (Lazier and
easier just to fix the compile errors by updating it. ;)
--
--Max Battcher--
http://worldmaker.net
More information about the darcs-users
mailing list