database-id-class (empty) → 0.1.0.0
raw patch · 5 files changed
+86/−0 lines, 5 filesdep +aesondep +basesetup-changed
Dependencies added: aeson, base
Files
- CHANGELOG.md +5/−0
- LICENSE +30/−0
- Setup.hs +2/−0
- database-id-class.cabal +21/−0
- src/Database/Id/Class.hs +28/−0
+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# Revision history for database-id-class++## 0.1.0.0++* Initial release. Contains HasId class and associated instances.
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2019, Obsidian Systems LLC++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Obsidian Systems LLC nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ database-id-class.cabal view
@@ -0,0 +1,21 @@+cabal-version: >=1.10+name: database-id-class+version: 0.1.0.0+synopsis: Class for types with a database id+description: Class for types with a database id+-- bug-reports:+license: BSD3+license-file: LICENSE+author: Obsidian Systems LLC+maintainer: maintainer@obsidian.systems+copyright: 2019 Obsidian Systems LLC+category: Database+build-type: Simple+extra-source-files: CHANGELOG.md++library+ exposed-modules: Database.Id.Class+ build-depends: base >=4.11 && <4.14+ , aeson+ hs-source-dirs: src+ default-language: Haskell2010
+ src/Database/Id/Class.hs view
@@ -0,0 +1,28 @@+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE UndecidableInstances #-}+module Database.Id.Class where++import Data.Aeson+import Data.Int+import Data.Typeable++-- | Class for types that have a database ID column+class HasId a where+ type IdData a :: *+ type IdData a = Int64++newtype Id a = Id { unId :: IdData a } deriving Typeable++deriving instance Read (IdData a) => Read (Id a)+deriving instance Show (IdData a) => Show (Id a)+deriving instance Eq (IdData a) => Eq (Id a)+deriving instance Ord (IdData a) => Ord (Id a)+deriving instance FromJSON (IdData a) => FromJSON (Id a)+deriving instance ToJSON (IdData a) => ToJSON (Id a)+deriving instance FromJSONKey (IdData a) => FromJSONKey (Id a)+deriving instance ToJSONKey (IdData a) => ToJSONKey (Id a)++data IdValue a = IdValue (Id a) a deriving Typeable