Only-0.1/0000755000000000000000000000000013117574734010475 5ustar0000000000000000Only-0.1/LICENSE0000644000000000000000000000300613117574734011501 0ustar0000000000000000Copyright (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-0.1/Setup.hs0000644000000000000000000000005613117574734012132 0ustar0000000000000000import Distribution.Simple main = defaultMain Only-0.1/Only.cabal0000644000000000000000000000176013117574734012406 0ustar0000000000000000name: 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 Only-0.1/src/0000755000000000000000000000000013117574734011264 5ustar0000000000000000Only-0.1/src/Data/0000755000000000000000000000000013117574734012135 5ustar0000000000000000Only-0.1/src/Data/Tuple/0000755000000000000000000000000013117574734013226 5ustar0000000000000000Only-0.1/src/Data/Tuple/Only.hs0000644000000000000000000000173413117574734014510 0ustar0000000000000000{-# 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