typeclasses / haskell-phrasebook

The Haskell Phrasebook: a quick intro to Haskell via small annotated example programs
https://typeclasses.com/phrasebook
210 stars 22 forks source link

Add time example #19

Closed tfausak closed 5 years ago

tfausak commented 5 years ago

I'm opening this PR more for discussion than anything else. Ostensibly it addresses #5, but the code as written doesn't provide any of the suggested examples.

I tried to perform a more-or-less direct translation of Go by Example: Time. Along the way I noticed several things:

In short, I feel like the Go example doesn't fit well into Haskell. Maybe things would be better with a different library. I think the Go example is a bit weird though, and shows off things I don't often do with time libraries.

I think the Haskell Phrasebook would be better off using some different examples. I'll spend some time tomorrow coming up with some more typical Haskell time usage.

chris-martin commented 5 years ago

Yeah. Time is one of those topics I haven't written about yet because the library is just not something I've ever felt like I wanted to show off. Another is CSV parsing, I've been down a huge rabbit whole trying to replace cassava for the sake of the Phrasebook. If I had all the free time in the world I'd work on a new time API. Maybe based on optics?

Here's a thought that might help provide focus: It seems to me that there are two somewhat disparate use cases for time:

Perhaps these are actually two fairly different subjects that deserve different pages?

tfausak commented 5 years ago

I feel your pain with time. I briefly looked at hourglass and thyme but didn't find a compelling reason to prefer their APIs.

Those two use cases just about cover it for me. I deal with the first much more regularly, and UTCTime covers it pretty well. I'll try to come up with something that addresses that case.

tfausak commented 5 years ago

Alright, I updated this with a vastly simplified example. I tried to stick to things that I actually do with times in Haskell. Briefly:

chris-martin commented 5 years ago

Looks great! This'll be released under the creative commons CC BY-NC 4.0 license - Please let us know if that's okay and how you'd like to be attributed.

tfausak commented 5 years ago

:+1: That license is great!

I'm not sure what you're asking about attribution --- what are my options for attribution? Or are you looking for something else, like my preferred name and pronouns?

chris-martin commented 5 years ago

Yeah, just name and I suppose a URL if you'd like a link to twitter or a blog or something in case just a name is ambiguous.

tfausak commented 5 years ago

Name: Taylor Fausak URL: https://taylor.fausak.me