packages feed

Only (empty) → 0.1

raw patch · 4 files changed

+97/−0 lines, 4 filesdep +basedep +deepseqdep +ghc-primsetup-changed

Dependencies added: base, deepseq, ghc-prim

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2017, Herbert Valerio Riedel++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 Herbert Valerio Riedel 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.
+ Only.cabal view
@@ -0,0 +1,32 @@+name:                Only+version:             0.1+synopsis:            The 1-tuple type or single-value "collection"+license:             BSD3+license-file:        LICENSE+author:              Herbert Valerio Riedel+maintainer:          hvr@gnu.org+bug-reports:         https://github.com/hvr/Only/issues+category:            Data+build-type:          Simple+cabal-version:       >=1.10+description:         This package provides the canonical anonymous 1-tuple type missing from Haskell for attaching typeclass instances.++Source-Repository head+  Type:              git+  Location:          https://github.com/hvr/Only.git++library+  hs-source-dirs:    src+  exposed-modules:   Data.Tuple.Only++  default-language:  Haskell2010+  other-extensions:  DeriveGeneric+                   , DeriveDataTypeable+                   , DeriveFunctor+                   , Safe++  build-depends:     base    >= 4.5 && <5+                   , deepseq >= 1.1 && <1.5++  if impl(ghc == 7.4.*)+     build-depends: ghc-prim
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/Data/Tuple/Only.hs view
@@ -0,0 +1,33 @@+{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE DeriveFunctor      #-}+{-# LANGUAGE DeriveGeneric      #-}+{-# LANGUAGE Safe               #-}++module Data.Tuple.Only where++import           Control.DeepSeq (NFData (rnf))+import           Data.Data       (Data)+import           Data.Typeable   (Typeable)+import           GHC.Generics    (Generic)++-- | The 1-tuple type or single-value "collection".+--+-- This type is structurally equivalent to the+-- 'Data.Functor.Identity.Identity' type, but its intent is more+-- about serving as the anonymous 1-tuple type missing from Haskell for attaching+-- typeclass instances.+--+-- Parameter usage example:+--+-- @encodeSomething ('Only' (42::Int))@+--+-- Result usage example:+--+-- @xs <- decodeSomething+--forM_ xs $ \\('Only' id) -> {- ... -}@+--+newtype Only a = Only { fromOnly :: a }+               deriving (Eq, Ord, Read, Show, Generic, Functor, Data, Typeable)++instance NFData a => NFData (Only a) where+    rnf = rnf . fromOnly