Skip to content

Commit

Permalink
[#70] Bump dependent-map to 0.5
Browse files Browse the repository at this point in the history
Resolves #70
  • Loading branch information
vrom911 committed Mar 27, 2019
1 parent 8744c9a commit cee1916
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 29 deletions.
35 changes: 8 additions & 27 deletions benchmark/DMap.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,27 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ViewPatterns #-}

{-# OPTIONS_GHC -fplugin GHC.TypeLits.KnownNat.Solver -fno-warn-orphans #-}
{-# OPTIONS_GHC -fplugin GHC.TypeLits.KnownNat.Solver #-}

module DMap
( spec
) where

import Criterion.Main (bench, nf, whnf, env)
import Criterion.Main (bench, env, nf, whnf)

import Prelude hiding (lookup)

import Spec
import Control.DeepSeq (NFData(..))
import Control.DeepSeq (NFData (..))
import Data.Maybe (fromJust)
import Data.Proxy (Proxy (..))
import Data.Type.Equality ((:~:) (..))
import GHC.TypeLits
import Spec
import Type.Reflection (TypeRep, Typeable, typeRep)
import Type.Reflection.Unsafe (typeRepFingerprint)
import Unsafe.Coerce (unsafeCoerce)

import Data.Dependent.Map (DMap, empty, insert, keys, lookup)
import Data.GADT.Compare (GCompare (..), GEq (..), GOrdering (..))
import Data.Some (Some (This))
import Data.Some (Some (Some))

type TypeRepMap = DMap TypeRep

Expand All @@ -40,7 +36,7 @@ spec = BenchSpec
{ benchLookup = Just $ \name ->
env mkBigMap $ \ ~(DMapNF bigMap) ->
bench name $ nf tenLookups bigMap
, benchInsertSmall = Just $ \name ->
, benchInsertSmall = Just $ \name ->
bench name $ whnf (inserts empty 10) (Proxy @ 99999)
, benchInsertBig = Just $ \name ->
env mkBigMap $ \ ~(DMapNF bigMap) ->
Expand Down Expand Up @@ -86,20 +82,5 @@ buildBigMap n x = insert (typeRep @a) x
newtype DMapNF f = DMapNF (TypeRepMap f)

instance NFData (DMapNF f) where
rnf (DMapNF x) =
rnf . map (\(This t) -> typeRepFingerprint t) $ keys x

instance GEq TypeRep where
geq :: TypeRep a -> TypeRep b -> Maybe (a :~: b)
geq (typeRepFingerprint -> a) (typeRepFingerprint -> b) =
if a == b
then Just $ unsafeCoerce Refl
else Nothing

instance GCompare TypeRep where
gcompare :: TypeRep a -> TypeRep b -> GOrdering a b
gcompare (typeRepFingerprint -> a) (typeRepFingerprint -> b) =
case compare a b of
EQ -> unsafeCoerce GEQ
LT -> GLT
GT -> GGT
rnf (DMapNF x) =
rnf . map (\(Some t) -> typeRepFingerprint t) $ keys x
3 changes: 2 additions & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
resolver: lts-13.4
resolver: lts-13.14

extra-deps:
- dependent-sum-0.5
- tasty-hedgehog-0.2.0.0
2 changes: 1 addition & 1 deletion typerep-map.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ benchmark typerep-map-benchmark
, criterion >= 1.4.1.0 && < 1.6
, deepseq ^>= 1.4.3.0
, dependent-map >= 0.2.4.0 && < 0.5
, dependent-sum ^>= 0.4
, dependent-sum ^>= 0.5
, ghc-typelits-knownnat >= 0.4.2 && < 0.7
, typerep-map
, typerep-extra-impls
Expand Down

0 comments on commit cee1916

Please sign in to comment.