Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ghcjs buildable version #52

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/dist/
dump/
.stack-work/
7 changes: 0 additions & 7 deletions include/thyme.h

This file was deleted.

156 changes: 0 additions & 156 deletions lens/Control/Lens.hs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Data/Thyme/Calendar.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}

#include "thyme.h"

#if HLINT
#include "cabal_macros.h"
#endif
Expand Down
54 changes: 21 additions & 33 deletions src/Data/Thyme/Calendar/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_HADDOCK hide #-}

#include "thyme.h"
#if HLINT
#include "cabal_macros.h"
#endif
Expand Down Expand Up @@ -59,7 +58,7 @@ type Days = Int
-- <https://en.wikipedia.org/wiki/Julian_day#Variants Modified Julian Day>
-- (MJD) epoch.
--
-- To convert a 'Day' to the corresponding 'YearMonthDay' in the W_GREGORIAN
-- To convert a 'Day' to the corresponding 'YearMonthDay' in the <https://en.wikipedia.org/wiki/Gregorian_calendar Gregorian>
-- calendar, see 'gregorian'.
--
-- @
Expand All @@ -84,7 +83,7 @@ type Days = Int
-- Other ways of viewing a 'Day' include 'ordinalDate', and 'weekDate'.
newtype Day = ModifiedJulianDay
{ toModifiedJulianDay :: Int
} deriving (INSTANCES_NEWTYPE, CoArbitrary)
} deriving (Eq, Ord, Data, Typeable, Generic, Enum, Ix, Hashable, NFData, CoArbitrary)

instance AffineSpace Day where
type Diff Day = Days
Expand All @@ -110,7 +109,7 @@ instance AffineSpace Day where
modifiedJulianDay :: Iso' Day Int
modifiedJulianDay = iso toModifiedJulianDay ModifiedJulianDay

-- | Conversion between a W_GREGORIAN 'OrdinalDate' and the corresponding
-- | Conversion between a <https://en.wikipedia.org/wiki/Gregorian_calendar Gregorian> 'OrdinalDate' and the corresponding
-- 'YearMonthDay'.
--
-- @
Expand Down Expand Up @@ -204,18 +203,14 @@ data YearMonthDay = YearMonthDay
{ ymdYear :: {-# UNPACK #-}!Year
, ymdMonth :: {-# UNPACK #-}!Month
, ymdDay :: {-# UNPACK #-}!DayOfMonth
} deriving (INSTANCES_USUAL, Show)

LENS(YearMonthDay,ymdYear,Year)
LENS(YearMonthDay,ymdMonth,Month)
LENS(YearMonthDay,ymdDay,DayOfMonth)
} deriving (Eq, Ord, Data, Typeable, Generic, Show)

instance Hashable YearMonthDay
instance NFData YearMonthDay

------------------------------------------------------------------------

-- | Is it a leap year according to the W_GREGORIAN calendar?
-- | Is it a leap year according to the <https://en.wikipedia.org/wiki/Gregorian_calendar Gregorian> calendar?
isLeapYear :: Year -> Bool
isLeapYear y = y .&. 3 == 0 && (r100 /= 0 || q100 .&. 3 == 0) where
(q100, r100) = y `quotRem` 100
Expand All @@ -228,10 +223,7 @@ type DayOfYear = Int
data OrdinalDate = OrdinalDate
{ odYear :: {-# UNPACK #-}!Year
, odDay :: {-# UNPACK #-}!DayOfYear
} deriving (INSTANCES_USUAL, Show)

LENS(OrdinalDate,odYear,Year)
LENS(OrdinalDate,odDay,DayOfYear)
} deriving (Eq, Ord, Data, Typeable, Generic, Show)

instance Hashable OrdinalDate
instance NFData OrdinalDate
Expand Down Expand Up @@ -368,10 +360,7 @@ randomIsoR l (x, y) = first (^. l) . randomR (l # x, l # y)
data MonthDay = MonthDay
{ mdMonth :: {-# UNPACK #-}!Month
, mdDay :: {-# UNPACK #-}!DayOfMonth
} deriving (INSTANCES_USUAL, Show)

LENS(MonthDay,mdMonth,Month)
LENS(MonthDay,mdDay,DayOfMonth)
} deriving (Eq, Ord, Data, Typeable, Generic, Show)

instance Hashable MonthDay
instance NFData MonthDay
Expand Down Expand Up @@ -512,11 +501,7 @@ data WeekDate = WeekDate
-- belong to the previous year.
, wdDay :: {-# UNPACK #-}!DayOfWeek
-- ^ /1 = Monday/ … /7 = Sunday/.
} deriving (INSTANCES_USUAL, Show)

LENS(WeekDate,wdYear,Year)
LENS(WeekDate,wdWeek,WeekOfYear)
LENS(WeekDate,wdDay,DayOfWeek)
} deriving (Eq, Ord, Data, Typeable, Generic, Show)

instance Hashable WeekDate
instance NFData WeekDate
Expand Down Expand Up @@ -602,11 +587,7 @@ data SundayWeek = SundayWeek
-- /Sunday/ of the year as the first day of week /01/.
, swDay :: {-# UNPACK #-}!DayOfWeek
-- ^ /0 = Sunday/.
} deriving (INSTANCES_USUAL, Show)

LENS(SundayWeek,swYear,Year)
LENS(SundayWeek,swWeek,WeekOfYear)
LENS(SundayWeek,swDay,DayOfWeek)
} deriving (Eq, Ord, Data, Typeable, Generic, Show)

instance Hashable SundayWeek
instance NFData SundayWeek
Expand Down Expand Up @@ -668,11 +649,7 @@ data MondayWeek = MondayWeek
-- /Monday/ of the year as the first day of week /01/.
, mwDay :: {-# UNPACK #-}!DayOfWeek
-- ^ /7 = Sunday/.
} deriving (INSTANCES_USUAL, Show)

LENS(MondayWeek,mwYear,Year)
LENS(MondayWeek,mwWeek,WeekOfYear)
LENS(MondayWeek,mwDay,DayOfWeek)
} deriving (Eq, Ord, Data, Typeable, Generic, Show)

instance Hashable MondayWeek
instance NFData MondayWeek
Expand Down Expand Up @@ -748,3 +725,14 @@ derivingUnbox "MondayWeek" [t| MondayWeek -> Int |]
[| \ MondayWeek {..} -> shiftL mwYear 9 .|. shiftL mwWeek 3 .|. mwDay |]
[| \ n -> MondayWeek (shiftR n 9) (shiftR n 3 .&. 0x3f) (n .&. 0x7) |]

makeLensesFor [("ymdYear","_ymdYear"),("ymdMonth","_ymdMonth"),("ymdDay","_ymdDay")] ''YearMonthDay

makeLensesFor [("odYear","_odYear"),("odDay","_odDay")] ''OrdinalDate

makeLensesFor [("mdMonth","_mdMonth"),("mdDay","_mdDay")] ''MonthDay

makeLensesFor [("wdYear","_wdYear"),("wdWeek","_wdWeek"),("wdDay","_wdDay")] ''WeekDate

makeLensesFor [("swYear","_swYear"),("swWeek","_swWeek"),("swDay","_swDay")] ''SundayWeek

makeLensesFor [("mwYear","_mwYear"),("mwWeek","_mwWeek"),("mwDay","_mwDay")] ''MondayWeek
2 changes: 1 addition & 1 deletion src/Data/Thyme/Calendar/MonthDay.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ViewPatterns #-}

#include "thyme.h"


-- | Calendar months and day-of-months.
module Data.Thyme.Calendar.MonthDay
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Thyme/Calendar/OrdinalDate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}

#include "thyme.h"

#if HLINT
#include "cabal_macros.h"
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Thyme/Calendar/WeekDate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{-# OPTIONS_GHC -fsimpl-tick-factor=120 #-} -- 7.6.3 only, it seems; fixes #29
#endif

#include "thyme.h"

#if HLINT
#include "cabal_macros.h"
#endif
Expand Down
9 changes: 2 additions & 7 deletions src/Data/Thyme/Calendar/WeekdayOfMonth.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ViewPatterns #-}

#include "thyme.h"
#if HLINT
#include "cabal_macros.h"
#endif
Expand Down Expand Up @@ -52,12 +51,7 @@ data WeekdayOfMonth = WeekdayOfMonth
-- last 'DayOfWeek' of the month.
, womDayOfWeek :: {-# UNPACK #-}!DayOfWeek
-- ^ Day of week. /1 = Monday, 7 = Sunday/, like ISO 8601 'WeekDate'.
} deriving (INSTANCES_USUAL, Show)

LENS(WeekdayOfMonth,womYear,Year)
LENS(WeekdayOfMonth,womMonth,Month)
LENS(WeekdayOfMonth,womNth,Int)
LENS(WeekdayOfMonth,womDayOfWeek,DayOfWeek)
} deriving (Eq, Ord, Data, Typeable, Generic, Show)

derivingUnbox "WeekdayOfMonth"
[t| WeekdayOfMonth -> Int |]
Expand Down Expand Up @@ -146,3 +140,4 @@ weekdayOfMonthValid (WeekdayOfMonth y m n wd) = (refDay .+^ s * offset)
wo = s * (wd - wd1)
offset = (abs n - 1) * 7 + if wo < 0 then wo + 7 else wo

makeLensesFor [("womYear","_womYear"),("womMonth","_womMonth"),("womNth","_womNth"),("womDayOfWeek","_womDayOfWeek")] ''WeekdayOfMonth
Loading