packages feed

hsqml-datamodel-vinyl 0.0.0.0 → 0.1.0.0

raw patch · 3 files changed

+7/−53 lines, 3 filesdep −show-typedep −template-haskell

Dependencies removed: show-type, template-haskell

Files

hsqml-datamodel-vinyl.cabal view
@@ -1,10 +1,7 @@--- Initial hsqml-datamodel-vinyl.cabal generated by cabal init.  For --- further documentation, see http://haskell.org/cabal/users-guide/- name:                hsqml-datamodel-vinyl-version:             0.0.0.0+version:             0.1.0.0 synopsis:            HsQML DataModel instances for Vinyl Rec.--- description:         +description:         HsQML DataModel instances for Vinyl Rec. Requires the field labels to be Typeable. license:             BSD3 license-file:        LICENSE author:              Marcin Mrotek@@ -25,13 +22,10 @@   manual:              True    library-  exposed-modules:     Graphics.QML.DataModel.Vinyl.TH-                       Graphics.QML.DataModel.Vinyl+  exposed-modules:     Graphics.QML.DataModel.Vinyl   build-depends:       base >=4.8 && <4.9                      , hsqml-datamodel                      , exceptions-                     , show-type-                     , template-haskell                      , type-list                      , vinyl   hs-source-dirs:      src
src/Graphics/QML/DataModel/Vinyl.hs view
@@ -18,7 +18,7 @@ Stability   : experimental  HsQML DataModel instances recursively defined for all 'Rec's.-'SetupColumns' requires the field labels to be instances of 'Showtype', which can be automatically declared using "Graphics.QML.DataModel.Vinyl.TH" module.+'SetupColumns' requires the field labels to be instances of 'Typeable'. -}  module Graphics.QML.DataModel.Vinyl where@@ -29,8 +29,8 @@ import Control.Exception import Data.Vinyl import Data.Type.List+import Data.Typeable import GHC.TypeLits-import Type.Showtype  instance CountFields (Rec f '[]) where   countFields _ = 0@@ -58,11 +58,11 @@   setupColumns _ _ = return ()  instance ( KnownNat (Length xs)-         , Showtype x+         , Typeable x          , SetupColumns (Rec f xs)          ) => SetupColumns (Rec f (x ': xs)) where   setupColumns hndl _ = do-       addHaskellModelRole hndl ix $ showtype (undefined :: sing x)+       addHaskellModelRole hndl ix . show $ typeRep (undefined :: proxy x)        setupColumns hndl (undefined :: sing (Rec f xs))     where ix = lengthVal (undefined :: sing xs) 
− src/Graphics/QML/DataModel/Vinyl/TH.hs
@@ -1,40 +0,0 @@-{-# OPTIONS_HADDOCK show-extensions #-}--{-# LANGUAGE TemplateHaskell #-}--{-|-Module      : Graphics.QML.DataModel.Vinyl.TH-Copyright   : (c) Marcin Mrotek, 2015-License     : BSD3-Maintainer  : marcin.jan.mrotek@gmail.com-Stability   : experimental---}--module Graphics.QML.DataModel.Vinyl.TH -  ( module Graphics.QML.DataModel.Vinyl.TH-  , module Graphics.QML.DataModel.Vinyl-  ) -  where--import Graphics.QML.DataModel.Vinyl()--import Control.Monad-import Language.Haskell.TH-import Type.Showtype--showTypes :: TypeQ -> DecsQ--- |Declare 'Showtype' instances for all labels in a given type-level list. Only works for explicit literals, unfortunately type synonyms and families aren't expanded.-showTypes types = return.concat =<< mapM inst =<< unwrapTypeList =<< types-  where -    inst t = [d| instance Showtype $(return t) where showtype _ = $(name t) |]-    name (PromotedT n) = stringE $ nameBase n-    name n = fail $ show n ++ " is not a promoted name."--unwrapTypeList :: Type -> Q [Type]--- |Unwraps a type-level list into a TH list of types.-unwrapTypeList (AppT PromotedConsT a) = return [a]-unwrapTypeList (AppT a b) = (++) <$> unwrapTypeList a <*> unwrapTypeList b-unwrapTypeList PromotedNilT = return []-unwrapTypeList a = fail $ "not a type list: " ++ show a-