Permalink
Browse files

Builds on 6.12.1

Actually, it *only* builds on 6.12.1 due to a compiler error in 6.10.4.
Updated now to work with newer versions of underlying libraries.
  • Loading branch information...
1 parent 261f7e0 commit 4419cd53e8170351d4ff5ff8212d126e677e1e1f @snoyberg committed Dec 23, 2009
Showing with 31 additions and 35 deletions.
  1. +19 −23 Data/Time/Calendar/Hebrew.hs
  2. +12 −12 hebrew-time.cabal
  3. 0 Test.hs → runtests.hs
@@ -1,7 +1,8 @@
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE CPP #-}
-{-# LANGUAGE OverloadedStrings #-}
---------------------------------------------------------
--
-- Module : Data.Time.Calendar.Hebrew
@@ -34,11 +35,10 @@ import Control.Arrow
import Control.Monad
import Data.Time.Calendar (Day (..), fromGregorian)
import Data.Time.Calendar.WeekDate (toWeekDate)
-import Data.Convertible
-
-import Data.Object
-import Data.Object.Text
-import Data.Object.Translate
+import Data.Typeable (Typeable)
+import Control.Exception (Exception)
+import qualified Safe.Failure as SF
+import Control.Failure
#if TEST
import Test.Framework (testGroup, Test)
@@ -48,6 +48,8 @@ import Test.HUnit hiding (Test)
import Test.QuickCheck
#endif
+import Data.Object
+
------ data definitions
data Month = Tishrei | Cheshvan | Kislev | Tevet | Shevat
| Adar | Adar1 | Adar2
@@ -58,6 +60,7 @@ data YearType = Chaser | Ksidran | Shlema
data YearLeap = Leap | NonLeap
deriving (Eq, Ord, Show, Enum)
+{- FIXME use some translation package
instance CanTranslate Month where
tryTranslate x "en" = Just $ convertSuccess $ show x
tryTranslate Tishrei "he" = Just "תשרי"
@@ -76,6 +79,7 @@ instance CanTranslate Month where
tryTranslate Elul "he" = Just "אלול"
defaultTranslate = convertSuccess . show
+-}
------ newtypes
newtype Chalakim = Chalakim Integer
@@ -550,21 +554,13 @@ instance Arbitrary HebrewDate where
y <- (+ 1) . (`mod` 6000) <$> arbitrary
day <- (+ 1) . (`mod` 29) <$> arbitrary
return $! HebrewDate y m day
-
------ Data.Object.Raw instances
-instance ToScalar Month Raw where
- toScalar = toScalar . show
-instance ToObject Month Raw Raw where
- toObject = Scalar . toScalar
-readM :: (Read r, Monad m) => String -> m r
-readM s = case reads s of
- ((x, _):_) -> return x
- _ -> fail $ "Unable to read: " ++ s
-instance FromScalar Month Raw where
- fromScalar (Raw bs) =
- case readM $ fromLazyByteString bs of
- Just x -> return x
- Nothing -> fail $ "Invalid hebrew month: " ++ fromLazyByteString bs -- FIXME don't use fail
-instance FromObject Month Raw Raw where
- fromObject = fromScalar <=< getScalar
#endif
+
+----- Data.Object.Text instances
+instance ConvertSuccess Month String where
+ convertSuccess = show
+instance ConvertAttempt String Month where
+ convertAttempt s = wrapFailure (\_ -> InvalidHebrewMonth s) $ SF.read s
+data InvalidHebrewMonth = InvalidHebrewMonth String
+ deriving (Show, Typeable)
+instance Exception InvalidHebrewMonth
View
@@ -18,23 +18,23 @@ flag buildtests
library
build-depends: base >= 4 && < 5,
- time >= 1.1.3,
- data-object >= 0.2.0,
- data-object-translate,
- convertible >= 1.2.0
+ time >= 1.1.3 && < 1.2,
+ data-object >= 0.2.0 && < 0.3,
+ failure >= 0.0.0 && < 0.1,
+ safe-failure >= 0.4.0 && < 0.5
exposed-modules: Data.Time.Calendar.Hebrew
ghc-options: -Wall
-Executable runtests
+executable runtests
if flag(buildtests)
Buildable: True
- cpp-options: -DTEST
- Build-depends: test-framework,
- test-framework-quickcheck,
- test-framework-hunit,
- HUnit,
- QuickCheck >= 1 && < 2
+ cpp-options: -DTEST
+ build-depends: test-framework,
+ test-framework-quickcheck,
+ test-framework-hunit,
+ HUnit,
+ QuickCheck >= 1 && < 2
else
Buildable: False
ghc-options: -Wall
- Main-Is: Test.hs
+ main-is: runtests.hs
View
File renamed without changes.

0 comments on commit 4419cd5

Please sign in to comment.