packages feed

instant-deepseq (empty) → 0.1

raw patch · 6 files changed

+127/−0 lines, 6 filesdep +basedep +deepseqdep +instant-genericssetup-changed

Dependencies added: base, deepseq, instant-generics

Files

+ CHANGELOG.md view
@@ -0,0 +1,3 @@+# Version 0.1++* First release
+ LICENSE.txt view
@@ -0,0 +1,30 @@+Copyright (c) 2015, Renzo Carbonara++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 Renzo Carbonara 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.
+ README.md view
@@ -0,0 +1,3 @@+`instant-deepseq` allows you to generically derive `Control.DeepSeq.NFData` instances+(from the `deepseq` package) for your types using `instant-generics`,+which in particular, supports deriving generic representations for GADTs.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ instant-deepseq.cabal view
@@ -0,0 +1,25 @@+name:                instant-deepseq+version:             0.1+author:              Renzo Carbonara+maintainer:          renzo@carbonara.com.ar+copyright:           Renzo Carbonara 2015+license:             BSD3+license-file:        LICENSE.txt+category:            Web+build-type:          Simple+extra-source-files:  README.md CHANGELOG.md+cabal-version:       >=1.18+synopsis:            Generic NFData instances through instant-generics++library+  hs-source-dirs: src/lib+  default-language: Haskell2010+  exposed-modules:+      Generics.Instant.Functions.DeepSeq+  build-depends:+      deepseq >=1.4 && <1.5+    , base >=4.8 && <4.9+    , instant-generics >=0.4 && <0.5+  ghcjs-options: -Wall -O3+  ghc-options: -Wall -O2+
+ src/lib/Generics/Instant/Functions/DeepSeq.hs view
@@ -0,0 +1,64 @@+{-# LANGUAGE BangPatterns #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE PolyKinds #-}++module Generics.Instant.Functions.DeepSeq+  ( -- $defaults+    grnf+    -- * Internals+  , GNFData+  ) where++import           Control.DeepSeq (NFData(rnf))+import           Generics.Instant++--------------------------------------------------------------------------------+-- $defaults+--+-- You can use 'grnf' as your generic 'rnf' for any 'Representable' type as+-- follows:+--+-- @+-- instance 'NFData' MyType where rnf = 'grnf'+-- @++grnf :: (Representable a, GNFData (Rep a)) => a -> ()+grnf = \a -> grnf' (from a)+{-# INLINABLE grnf #-}++--------------------------------------------------------------------------------++class GNFData a where+  grnf' :: a -> ()++instance GNFData Z where+  grnf' _ = error+    "Generics.Instant.Functions.DeepSeq.GNFData Z grnf' - impossible"++instance GNFData U where+  grnf' !U = ()+  {-# INLINABLE grnf' #-}++instance GNFData a => GNFData (CEq c p q a) where+  grnf' !(C a) = grnf' a `seq` ()+  {-# INLINABLE grnf' #-}++instance (GNFData a, GNFData b) => GNFData (a :*: b) where+  grnf' !(a :*: b) = grnf' a `seq` grnf' b `seq` ()+  {-# INLINABLE grnf' #-}++instance (GNFData a, GNFData b) => GNFData (a :+: b) where+  grnf' !(L a) = grnf' a `seq` ()+  grnf' !(R b) = grnf' b `seq` ()+  {-# INLINABLE grnf' #-}++instance NFData a => GNFData (Var a) where+  grnf' !(Var a) = rnf a `seq` ()+  {-# INLINABLE grnf' #-}++instance NFData a => GNFData (Rec a) where+  grnf' !(Rec a) = rnf a `seq` ()+  {-# INLINABLE grnf' #-}