summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPepeIborra <>2018-10-06 15:49:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2018-10-06 15:49:00 (GMT)
commit56eb8cdec3b46ae7e0e5a5247d98d1b19e4c059f (patch)
treec812c45b306a2db283cbc129ba2bb9a9a57dc6d0
parent68446b51275f72f7687b2e6846356eaa1123be7f (diff)
version 0.1.3HEAD0.1.3master
-rw-r--r--src/Data/Strict/Forced.hs35
-rw-r--r--src/Data/Strict/HashMap.hs33
-rw-r--r--strict-types.cabal2
3 files changed, 41 insertions, 29 deletions
diff --git a/src/Data/Strict/Forced.hs b/src/Data/Strict/Forced.hs
index da114a5..a58c74d 100644
--- a/src/Data/Strict/Forced.hs
+++ b/src/Data/Strict/Forced.hs
@@ -1,9 +1,9 @@
-{-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE FlexibleInstances #-}
-{-# LANGUAGE DeriveFoldable #-}
-{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE DeriveFoldable #-}
+{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE PatternSynonyms #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE PatternSynonyms #-}
+{-# LANGUAGE TypeFamilies #-}
module Data.Strict.Forced
(
Forced (Forced, getForced)
@@ -12,12 +12,18 @@ module Data.Strict.Forced
, (<!>)
) where
-import Control.Arrow
-import Control.DeepSeq
-import Data.Hashable
-import GHC.Exts
-import GHC.Float
-import Type.Strict
+import Control.Arrow
+import Control.DeepSeq
+import Data.Hashable
+import Data.Semigroup (Semigroup(..))
+import GHC.Exts
+import GHC.Float
+import Prelude (Applicative (..), Bounded (..), Enum (..),
+ Eq (..), Foldable (..), Fractional (..), Functor(..),
+ Integral (..), Monoid (..), Num (..),
+ Ord (..), Read (..), Real (..), RealFrac (..),
+ Show (..), (<$>), (.))
+import Type.Strict
-- | A newtype to enforce rigid normal form evaluation.
newtype Forced a = Forced_ a
@@ -49,9 +55,12 @@ instance NFData (Forced a) where rnf _ = ()
instance (NFData a, Read a) => Read(Forced a) where
readsPrec p inp = [ (Forced x, rest) | (x, rest) <- readsPrec p inp ]
-instance (NFData a, Monoid a) => Monoid (Forced a) where
+instance (Semigroup a, NFData a, Monoid a) => Monoid (Forced a) where
mempty = Forced mempty
- mappend (Forced a) (Forced b) = Forced (mappend a b)
+ mappend = (<>)
+
+instance (NFData a, Semigroup a) => Semigroup (Forced a) where
+ Forced a <> Forced b = Forced (a <> b)
instance (NFData a, Bounded a) => Bounded (Forced a) where
minBound = Forced minBound
diff --git a/src/Data/Strict/HashMap.hs b/src/Data/Strict/HashMap.hs
index 6bb043b..2ce6e44 100644
--- a/src/Data/Strict/HashMap.hs
+++ b/src/Data/Strict/HashMap.hs
@@ -1,8 +1,8 @@
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE TypeFamilies #-}
-{-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE TypeFamilies #-}
-- | A wrapper around 'H.HashMap' from the unordered-containers package,
-- with the aim of fixing the strictness of the type class operations,
@@ -50,17 +50,20 @@ module Data.Strict.HashMap
, (!)
)where
-import Prelude hiding (filter, foldr, lookup, map, null)
-import Control.DeepSeq
-import Data.Bifunctor
-import Data.Data
-import Data.Functor.Classes
-import Data.Hashable
-import Data.Hashable.Lifted
-import qualified Data.HashMap.Strict as H
-import Data.Semigroup
-import GHC.Exts
-import Type.Strict hiding (Strict)
+import Control.DeepSeq
+import Data.Bifunctor
+import Data.Data
+import Data.Functor.Classes
+import Data.Hashable
+import Data.Hashable.Lifted
+import qualified Data.HashMap.Strict as H
+import Data.Semigroup
+import GHC.Exts
+import Prelude (Applicative (..), Bool (..), Eq (..),
+ Foldable, Functor (..), Maybe (..),
+ Monoid (..), Read (..), Show (..),
+ Traversable (..), const, id, (.), (<$>))
+import Type.Strict hiding (Strict)
newtype HashMap k a = Strict { getStrict :: H.HashMap k a}
deriving (Data, NFData, Eq, Show, Eq1, Show1, Eq2, Show2, Hashable, Hashable1, Hashable2, Foldable, Semigroup, Monoid)
diff --git a/strict-types.cabal b/strict-types.cabal
index 9185cd1..f6c76bc 100644
--- a/strict-types.cabal
+++ b/strict-types.cabal
@@ -1,6 +1,6 @@
name: strict-types
author: Pepe Iborra
-version: 0.1.2
+version: 0.1.3
license: BSD3
license-file: LICENSE
copyright: Jose Iborra Lopez, 2017