composite-hashable (empty) → 0.7.4.0
raw patch · 3 files changed
+51/−0 lines, 3 filesdep +basedep +composite-basedep +hashablesetup-changed
Dependencies added: base, composite-base, hashable
Files
- Setup.hs +2/−0
- composite-hashable.cabal +34/−0
- src/Composite/Record/Hashable.hs +15/−0
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ composite-hashable.cabal view
@@ -0,0 +1,34 @@+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.33.0.+--+-- see: https://github.com/sol/hpack+--+-- hash: 0c8bfc8ec3ee0943c5b055ead5ee34438c950c754e4627217c9bcda776d629c6++name: composite-hashable+version: 0.7.4.0+synopsis: Orphan hashable instances.+description: Hashable instance for (:->) and Record.+category: Records+homepage: https://github.com/ConferOpenSource/composite#readme+author: Confer Health, Inc+maintainer: oss@vitalbio.com+copyright: 2017 Confer Health, Inc., 2020 Vital Biosciences+license: BSD3+build-type: Simple++library+ exposed-modules:+ Composite.Record.Hashable+ other-modules:+ Paths_composite_hashable+ hs-source-dirs:+ src+ default-extensions: DataKinds FlexibleContexts FlexibleInstances GeneralizedNewtypeDeriving LambdaCase MultiParamTypeClasses MultiWayIf OverloadedStrings PatternSynonyms PolyKinds QuasiQuotes RankNTypes ScopedTypeVariables StandaloneDeriving StrictData TemplateHaskell TupleSections TypeFamilies TypeOperators ViewPatterns+ ghc-options: -Wall -O2+ build-depends:+ base >=4.7 && <5+ , composite-base >=0.7 && <0.8+ , hashable >=1.1.1 && <1.4+ default-language: Haskell2010
+ src/Composite/Record/Hashable.hs view
@@ -0,0 +1,15 @@+{-# LANGUAGE UndecidableInstances #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+module Composite.Record.Hashable where++import Composite.Record((:->), Record, Rec(RNil, (:&)), getVal)+import Data.Hashable(Hashable(hashWithSalt))++instance Hashable a => Hashable (s :-> a) where+ hashWithSalt n x = hashWithSalt n $ getVal x++instance Hashable (Record '[]) where+ hashWithSalt n RNil = n `hashWithSalt` ()++instance (Hashable x, Hashable (Record xs)) => Hashable (Record (x : xs)) where+ hashWithSalt n (x :& xs) = n `hashWithSalt` x `hashWithSalt` xs