Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding Data.Object.Dangerous

  • Loading branch information...
commit 473ceeee7eff78576009760041af0f002b3563d9 1 parent 5f64bfd
@snoyberg authored
Showing with 36 additions and 0 deletions.
  1. +35 −0 Data/Object/Dangerous.hs
  2. +1 −0  data-object.cabal
View
35 Data/Object/Dangerous.hs
@@ -0,0 +1,35 @@
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE UndecidableInstances #-}
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+-- | This module enables all the dangerous instances that make this library
+-- easy to use. Caveat emptor!
+module Data.Object.Dangerous
+ (
+ ) where
+
+import Data.Object.Base
+import Data.Convertible.Text
+
+instance ToObject x k v => ConvertSuccess x (Object k v) where
+ convertSuccess = toObject
+{- This is too dangerous even for Dangerous ;).
+ - It requires IncoherentInstances, since we have
+ - ConvertSuccess => ConvertAttempt in convertible-text
+instance FromObject x k v => ConvertAttempt (Object k v) x where
+ convertAttempt = fromObject
+-}
+
+instance ToObject (Object kIn vIn) kOut vOut
+ => FromObject (Object kOut vOut) kIn vIn where
+ fromObject = return . toObject
+
+instance (ConvertSuccess kIn kOut, ConvertSuccess vIn vOut)
+ => ToObject (Object kIn vIn) kOut vOut where
+ toObject = mapKeysValues convertSuccess convertSuccess
+
+instance ToObject v k v where
+ toObject = Scalar
+instance FromObject v k v where
+ fromObject = fromScalar
View
1  data-object.cabal
@@ -38,6 +38,7 @@ library
Data.Object.Text
Data.Object.Scalar
Data.Object.String
+ Data.Object.Dangerous
ghc-options: -Wall
executable runtests
Please sign in to comment.
Something went wrong with that request. Please try again.