David Thomas | 28 Nov 05:56 2012
Picon

Recursive timezone-loading function

https://github.com/dlthomas/tzcache

A small bit of code, but seems likely to be useful enough that I figured I should share.

I've a few notes/questions:

1) Does this already exist somewhere I missed?

2) It seems silly to make this its own library - any suggestions where it could be added?

3) Is the traverse-a-directory-and-populate-a-map pattern one worth abstracting?  If so, where should that go?

4) Presently, it's a static cache entirely pre-loaded.  This seems fine, as it's not a terribly huge amount of data, but it's worth noting.

5) Any comments on the code generally?  Improvements?  Complaints?

Thanks,

- David
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Yitzchak Gale | 29 Nov 23:28 2012

Re: Recursive timezone-loading function

Hi David,

David Thomas wrote:
https://github.com/dlthomas/tzcache
A small bit of code, but seems likely to be useful enough that I figured I should share.

Thanks for sharing this!
 
1) Does this already exist somewhere I missed?

I haven't seen it anywhere.
 
2) It seems silly to make this its own library 
- any suggestions where it could be added?

If you feel it is appropriate, I would be willing to add it
to timezone-olson. Does anyone else have an opinion
about it?

3) Is the traverse-a-directory-and-populate-a-map 
pattern one worth abstracting?  If so, where should that go?

I think the proper abstraction would be a more
general fold or traversal over a directory structure.
Some languages have something like that (e.g.,
os.walk in Python). But look how simply it worked
out for you in Haskell - perhaps that's why there
doesn't seem to be a standard function for this
anywhere. That said, it might be interesting to
have this as a lens-package-style traversal.

4) Presently, it's a static cache entirely pre-loaded. 
This seems fine, as it's not a terribly huge amount 
of data, but it's worth noting.

Yes. The total amount of timezone data in the world
is likely to continue increasing at a significantly
slower rate than Moore's law.

5) Any comments on the code generally? 
Improvements?  Complaints?

I like your code. I'm not sure how well this
brute-force mapM recursion would scale over
a timezone directory structure with, say, millions
of nodes. But that's not the use case here at all.

Thanks,
Yitz
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Roman Cheplyaka | 29 Nov 23:46 2012

Re: Recursive timezone-loading function

* Yitzchak Gale <gale <at> sefer.org> [2012-11-30 00:28:45+0200]
> I think the proper abstraction would be a more
> general fold or traversal over a directory structure.
> Some languages have something like that (e.g.,
> os.walk in Python).

Check out http://hackage.haskell.org/packages/archive/filemanip/latest/doc/html/System-FilePath-Find.html

Roman

Gmane