Skip to content
Browse files

use newtype to avoid orphan instance

  • Loading branch information...
1 parent 329c9ac commit e53c73e68364857d0f02c63ce65c6226c19cadbc @gregwebs gregwebs committed Aug 5, 2012
Showing with 7 additions and 4 deletions.
  1. +7 −4 persistent-mongoDB/Database/Persist/MongoDB.hs
View
11 persistent-mongoDB/Database/Persist/MongoDB.hs
@@ -66,9 +66,12 @@ import Data.Attoparsec.Number
import FileLocation (debug)
#endif
-instance FromJSON NominalDiffTime where
- parseJSON (Number (I x)) = (return . fromInteger) x
- parseJSON (Number (D x)) = (return . fromRational . toRational) x
+newtype NoOrphanNominalDiffTime = NoOrphanNominalDiffTime NominalDiffTime
+ deriving Num
+
+instance FromJSON NoOrphanNominalDiffTime where
+ parseJSON (Number (I x)) = (return . NoOrphanNominalDiffTime . fromInteger) x
+ parseJSON (Number (D x)) = (return . NoOrphanNominalDiffTime . fromRational . toRational) x
parseJSON _ = fail "couldn't parse diff time"
data Connection = Connection DB.Pipe DB.Database
@@ -585,7 +588,7 @@ instance PersistConfig MongoConf where
host <- o .:? "host" .!= "127.0.0.1"
poolStripes <- o .:? "poolstripes" .!= 1
stripeConnections <- o .: "connections"
- connectionIdleTime <- o .:? "connectionIdleTime" .!= 20
+ (NoOrphanNominalDiffTime connectionIdleTime) <- o .:? "connectionIdleTime" .!= 20
mUser <- o .:? "user"
mPass <- o .:? "password"
accessString <- o .:? "accessMode" .!= "ConfirmWrites"

0 comments on commit e53c73e

Please sign in to comment.
Something went wrong with that request. Please try again.