You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given a Day you can get the year, month, and day as a tuple by writing fromGregorian day. Getting the year requires pattern matching on a 3-tuple or using lens' to get the first field. I think it's a common enough operation that it might be worth defining a convenience function called gregorianYear or year in the Gregorian package.
The text was updated successfully, but these errors were encountered:
mchav
changed the title
Add convenience function to get year DAy
Add convenience function to get year from Day
Dec 22, 2024
Yeah that's what I was referring to by tuple matching.
This might be too niche a request but figured it'd be good to ask anyway. I'm working on a dataframe library and I'm porting some datetime related examples from Python. For people starting out with Haskell and I suggest the approach you mention in the tutorial but I thought this might be the sort of thing that makes that would make the library easier to use so could be an upstream change.
So the above example would make sense to write as:
I also just realized your approach is different from the tuple approach. Sorry. Should have read that more closely. I guess that makes my concern less pressing but the gist of it still holds, I think.
Given a Day you can get the year, month, and day as a tuple by writing
fromGregorian day
. Getting the year requires pattern matching on a 3-tuple or using lens' to get the first field. I think it's a common enough operation that it might be worth defining a convenience function calledgregorianYear
oryear
in the Gregorian package.The text was updated successfully, but these errors were encountered: