packages feed

aeson-flowtyped 0.8.0 → 0.8.1

raw patch · 3 files changed

+25/−19 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Data.Aeson.Flow: instance (Data.Typeable.Internal.Typeable a, GHC.TypeLits.KnownNat a, v ~ Data.Aeson.Flow.Var a) => Data.Aeson.Flow.FlowTyped (Data.Tree.Tree v)
- Data.Aeson.Flow: instance Data.Typeable.Internal.Typeable a => Data.Aeson.Flow.FlowTyped (Data.Aeson.Flow.Var a)
+ Data.Aeson.Flow: instance Data.Typeable.Internal.Typeable a => Data.Aeson.Flow.FlowTyped (Data.Tree.Tree a)
+ Data.Aeson.Flow: instance forall k (k1 :: k) k2 (a :: k2). (Data.Typeable.Internal.Typeable a, Data.Typeable.Internal.Typeable k2) => Data.Aeson.Flow.FlowTyped (Data.Aeson.Flow.Var a)
- Data.Aeson.Flow: data Var :: Nat -> Type
+ Data.Aeson.Flow: data Var :: k -> Type

Files

aeson-flowtyped.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack  name:           aeson-flowtyped-version:        0.8.0+version:        0.8.1 synopsis:       Create Flow type definitions from Haskell data types. description:    Create Flow type definitions from Haskell data types. category:       Web
src/Data/Aeson/Flow.hs view
@@ -85,6 +85,7 @@ import qualified Data.Vector.Unboxed              as VU import qualified Data.Void                        as Void import           Data.Word+import           Data.Maybe import           GHC.Generics import           GHC.TypeLits import qualified Text.PrettyPrint.Leijen          as PP@@ -368,13 +369,17 @@     pGetName _ = Proxy  flowTypePreferName :: (Typeable a, FlowTyped a) => Proxy a -> FlowType-flowTypePreferName p = case flowTypeName p of-  Just n | null vars -> name-         | otherwise -> Fix (PolyApply name vars)+flowTypePreferName p = fromMaybe (flowType p) (flowTypeRecur p)++flowTypeRecur :: (Typeable a, FlowTyped a) => Proxy a -> Maybe FlowType+flowTypeRecur p = case flowTypeName p of+  Just n+    | null vars -> Just name+    | otherwise -> Just (Fix (PolyApply name vars))     where       vars = flowTypeVars p       name = Fix (Name (FlowName p n))-  Nothing -> flowType p+  Nothing -> Nothing  class Typeable a => FlowTyped a where   flowType :: Proxy a -> FlowType@@ -693,25 +698,25 @@   flowType _ = Fix (Array (flowTypePreferName (Proxy :: Proxy a)))   flowTypeName _ = Nothing -data Var :: Nat -> Type where Var :: Var a+data Var :: k -> Type where Var :: Var a -instance Typeable a => FlowTyped (Var a) where+instance (Typeable a, Typeable k) => FlowTyped (Var (a :: k)) where   isPrim _ = False-  flowType _ = Fix (PolyVar (typeRep (Proxy :: Proxy (Var a))))+  flowType _ = Fix (PolyVar (typeRep (Var :: Var a)))   flowTypeName _ = Nothing  -- | This instance is defined recursively. You'll probably need to use -- 'dependencies' to extract a usable definition-instance (Typeable a, KnownNat a, v ~ Var a) => FlowTyped (Tree.Tree v) where+instance Typeable a => FlowTyped (Tree.Tree a) where   isPrim _ = False-  flowType _ = Fix-    (Tuple-     (V.fromList-      [ flowType (Proxy :: Proxy v)-      , Fix (Array (flowTypePreferName (Proxy :: Proxy (Tree.Tree v))))-      ]))+  flowType _ = Fix (Tuple+                    (V.fromList+                     [ flowType (Proxy :: Proxy (Var a))+                     , Fix (Array+                            (fromJust (flowTypeRecur (Proxy :: Proxy (Tree.Tree a)))))+                     ]))   flowTypeName _ = Just "Tree"-  flowTypeVars _ = [typeRep (Proxy :: Proxy v)]+  flowTypeVars _ = [typeRep (Var :: Var a)]  instance FlowTyped () where   isPrim _ = False
test/Spec.hs view
@@ -56,10 +56,11 @@ data Poly2 a b = Poly2 a b | Poly2Go (Poly2 a b)   deriving (Generic) -instance (a ~ Var 0, b ~ Var 1) => FlowTyped (Poly2 a b) where+instance (Typeable a, FlowTyped a, Typeable b, FlowTyped b) =>+         FlowTyped (Poly2 a b) where   flowTypeVars _ =-    [ typeRep (Proxy :: Proxy a)-    , typeRep (Proxy :: Proxy b)+    [ typeRep (Var :: Var 0)+    , typeRep (Var :: Var 1)     ]  main :: IO ()