@@ -1,8 +1,9 @@
11{-# OPTIONS_HADDOCK hide #-}
2+{-# LANGUAGE CPP #-}
23-----------------------------------------------------------------------------
34-- |
45-- Module : Data.Time.LocalTime.TimeZone.Olson.Types
5−-- Copyright : Yitzchak Gale 2010
6+-- Copyright : Yitzchak Gale 2018
67--
78-- Maintainer : Yitzchak Gale <gale@sefer.org>
89-- Portability : portable
@@ -36,6 +37,9 @@ module Data.Time.LocalTime.TimeZone.Olson.Types
3637)
3738where
3839
40+#if MIN_VERSION_base(4,11,0)
41+import Data.Semigroup (Semigroup(..))
42+#endif
3943import Data.Monoid (Monoid(..))
4044import Control.Monad (mplus)
4145
@@ -71,6 +75,17 @@ data OlsonData =
7175 }
7276 deriving (Eq, Show)
7377
78+#if MIN_VERSION_base(4,11,0)
79+instance Semigroup OlsonData where
80+ OlsonData a b c d <> OlsonData a' b' c' d' =
81+ OlsonData (a ++ map (shiftBy $ length b) a')
82+ (b ++ b') (c ++ c') (d `mplus` d')
83+ where
84+ shiftBy n trans = trans {transIndex = n + transIndex trans}
85+
86+instance Monoid OlsonData where
87+ mempty = OlsonData [] [] [] Nothing
88+#else
7489instance Monoid OlsonData where
7590 mempty = OlsonData [] [] [] Nothing
7691 mappend (OlsonData a b c d ) (OlsonData a' b' c' d') =
@@ -78,6 +93,7 @@ instance Monoid OlsonData where
7893 (b ++ b') (c ++ c') (d `mplus` d')
7994 where
8095 shiftBy n trans = trans {transIndex = n + transIndex trans}
96+#endif
8197
8298-- | A @Transition@ represents a moment when the clocks change in a
8399-- timezone. It consists of a Unix timestamp value that indicates the