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
With the advent of 0.15.0 and type-level integers, we can now define Date and Time components without using unsafePartial:
hour
::foralli
. ReflectableiInt=>PI.Comparei (-1) PO.GT=>PI.Comparei 24 PO.LT=>Proxyi->Hour
hour p = Hour $ reflectType p
minute
::foralli
. ReflectableiInt=>PI.Comparei (-1) PO.GT=>PI.Comparei 60 PO.LT=>Proxyi->Minute
minute p = Minute $ reflectType p
second
::foralli
. ReflectableiInt=>PI.Comparei (-1) PO.GT=>PI.Comparei 60 PO.LT=>Proxyi->Second
second p = Second $ reflectType p
millisecond
::foralli
. ReflectableiInt=>PI.Comparei (-1) PO.GT=>PI.Comparei 1_000 PO.LT=>Proxyi->Millisecond
millisecond p = Millisecond $ reflectType p
year
::foralli
. ReflectableiInt=>PI.Comparei (-271821) PO.GT=>PI.Comparei 275760 PO.LT=>Proxyi->Year
year p = Year $ reflectType p
month
::foralli
. ReflectableiInt=>PI.Comparei 0 PO.GT=>PI.Comparei 13 PO.LT=>Proxyi->Month
month p = unsafePartial $ fromJust $ toEnum $ reflectType p
day
::foralli
. ReflectableiInt=>PI.Comparei 0 PO.GT=>PI.Comparei 32 PO.LT=>Proxyi->Day
day p = Day $ reflectType p
I would like to add a similar constructor for DateTime based on exactDate, but that requires verifying at the type-level that the day is within the bounds for the month-year combination. If we wanted to lift the isLeapYear function to the type-level, it seems we'll need a Prim.Int (class Mod) type class.
The text was updated successfully, but these errors were encountered:
I would like to add a similar constructor for DateTime based on exactDate, but that requires verifying at the type-level that the day is within the bounds for the month-year combination. If we wanted to lift the isLeapYear function to the type-level, it seems we'll need a Prim.Int (class Mod) type class.
I think this could be implemented as:
exactDate
::forallyearmonthdaymaxDayupperBound
. ReflectableyearInt=>PI.Compareyear (-271821) PO.GT=>PI.Compareyear 275760 PO.LT=>ReflectablemonthInt=>PI.Comparemonth 0 PO.GT=>PI.Comparemonth 13 PO.LT=>ReflectabledayInt=>MaxMonthDayyearmonthmaxDay=>PI.AddmaxDay 1 upperBound=>PI.Comparei 0 PO.GT=>PI.CompareiupperBoundPO.LT=>Proxyyear->Proxymonth->Proxyday->Date
exactDate y m d = Date (DC.year y) (DC.month m) (DC.day d)
With the advent of
0.15.0
and type-level integers, we can now defineDate
andTime
components without usingunsafePartial
:I would like to add a similar constructor for
DateTime
based onexactDate
, but that requires verifying at the type-level that the day is within the bounds for the month-year combination. If we wanted to lift theisLeapYear
function to the type-level, it seems we'll need aPrim.Int (class Mod)
type class.The text was updated successfully, but these errors were encountered: