[Haskell-cafe] Sillyness in the standard libs.
LS, here is a puzzle for you: try converting a System.Posix.Types.EpochTime into either a System.Time.CalendarTime or a Data.Time.Clock.UTCTime without going through read . show or a similar detour through strings. The problem comes up when trying to easily nicely display the access, modification or status change times of a full directory of files, using System.Posix.Files.Filestatus to get at the times. A closely related issue: fromIntegral is in Integral which also requires quotRem. However, the two are semantically quite disjoint. I can *easily* see the semantics of fromIntegral on EpochTime, but not the semantics of quotRem on EpochTime. Having fromIntegral would solve the above puzzle... :) With kind regards, Arthur. -- /\/ | [EMAIL PROTECTED] | Work like you don't need the money /__\ / | A friend is someone with whom | Love like you have never been hurt /\/__ | you can dare to be yourself | Dance like there's nobody watching ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Sillyness in the standard libs.
On Nov 19, 2007, at 16:06 , Arthur van Leeuwen wrote: here is a puzzle for you: try converting a System.Posix.Types.EpochTime into either a System.Time.CalendarTime or a Data.Time.Clock.UTCTime without going through read . show or a similar detour through strings. fromEnum and/or toEnum are helpful for this kind of thing, and I am occasionally tempted to bind cast = toEnum . fromEnum because I need it so much. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED] system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED] electrical and computer engineering, carnegie mellon universityKF8NH ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Sillyness in the standard libs.
On Mon, 19 Nov 2007, Brandon S. Allbery KF8NH wrote: On Nov 19, 2007, at 16:06 , Arthur van Leeuwen wrote: here is a puzzle for you: try converting a System.Posix.Types.EpochTime into either a System.Time.CalendarTime or a Data.Time.Clock.UTCTime without going through read . show or a similar detour through strings. fromEnum and/or toEnum are helpful for this kind of thing, and I am occasionally tempted to bind cast = toEnum . fromEnum because I need it so much. Really? I'd like to know which examples these are. So far I suspected that 'cast' indicates not well chosen types. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Sillyness in the standard libs.
Arthur van Leeuwen wrote: A closely related issue: fromIntegral is in Integral which also requires quotRem. However, the two are semantically quite disjoint. I can *easily* see the semantics of fromIntegral on EpochTime, but not the semantics of quotRem on EpochTime. Having fromIntegral would solve the above puzzle... :) As I understand it, it's widely recognised that Haskell's current numeric class hierachy is broken (or at best, not very well chosen), but nobody came up with a better suggestion yet. (By all means, somebody correct me if I'm wrong here...!) Also, that hierachy is in the Haskell Report, so we'll have to wait for Haskell' to fix it for good. (Although you can roll you own right now - if you can think of a better design...) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Sillyness in the standard libs.
On Mon, 19 Nov 2007, Andrew Coppin wrote: Arthur van Leeuwen wrote: A closely related issue: fromIntegral is in Integral which also requires quotRem. However, the two are semantically quite disjoint. I can *easily* see the semantics of fromIntegral on EpochTime, but not the semantics of quotRem on EpochTime. Having fromIntegral would solve the above puzzle... :) As I understand it, it's widely recognised that Haskell's current numeric class hierachy is broken (or at best, not very well chosen), but nobody came up with a better suggestion yet. (By all means, somebody correct me if I'm wrong here...!) http://www.haskell.org/haskellwiki/Mathematical_prelude_discussion http://www.haskell.org/haskellwiki/Libraries_and_tools/Mathematics#Type_class_hierarchies ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Sillyness in the standard libs.
On Nov 19, 2007, at 16:50 , Henning Thielemann wrote: On Mon, 19 Nov 2007, Brandon S. Allbery KF8NH wrote: fromEnum and/or toEnum are helpful for this kind of thing, and I am occasionally tempted to bind cast = toEnum . fromEnum because I need it so much. Really? I'd like to know which examples these are. So far I suspected that 'cast' indicates not well chosen types. If so, it's not my types... The specific instance is the one you mentioned about times; fromEnum lets me turn a Foreign.C.Types.CTime (== System.Posix.Types.EpochTime) to an Int (which is commonly just type punning in GHC, since it's the same internal value representation in most (all?) cases), from which I can get to another Foreign.C.Types type with toEnum or to Integer with fromIntegral. (NB: This involves an assumption about CTime; POSIX allows (or used to allow) it to be a floating type in order to allow some non- UNIXlikes to represent POSIX times. But given that CTime is Enum, Foreign.C.Types already violates this; so why isn't it also Integral?) So yes, this is a sign of typing issues in the implementation and (toEnum . fromEnum) is a hack around them. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED] system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED] electrical and computer engineering, carnegie mellon universityKF8NH ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Sillyness in the standard libs.
On Nov 19, 2007, at 17:10 , Brandon S. Allbery KF8NH wrote: CTime; POSIX allows (or used to allow) it to be a floating type in order to allow some non-UNIXlikes to represent POSIX times. But given that CTime is Enum, Foreign.C.Types already violates this; so why isn't it Hrm, not thinking about that right, Enum works for Floating. Never mind... -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED] system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED] electrical and computer engineering, carnegie mellon universityKF8NH ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe