void 0.5.12 → 0.6
raw patch · 10 files changed
+227/−129 lines, 10 filesdep +ghc-primdep +hashable
Dependencies added: ghc-prim, hashable
Files
- .ghci +1/−0
- .gitignore +15/−0
- .vim.custom +31/−0
- CHANGELOG.markdown +6/−0
- Data/Void.hs +0/−76
- Data/Void/Unsafe.hs +0/−48
- LICENSE +1/−1
- src/Data/Void.hs +108/−0
- src/Data/Void/Unsafe.hs +47/−0
- void.cabal +18/−4
+ .ghci view
@@ -0,0 +1,1 @@+:set -isrc -idist/build/autogen -optP-include -optPdist/build/autogen/cabal_macros.h
+ .gitignore view
@@ -0,0 +1,15 @@+*#+*.hi+*.o+*~+.*.swo+.*.swp+.swp+.DS_Store+TAGS+_darcs+dist+docs+tags+wiki+wip
+ .vim.custom view
@@ -0,0 +1,31 @@+" Add the following to your .vimrc to automatically load this on startup++" if filereadable(".vim.custom")+" so .vim.custom+" endif++function StripTrailingWhitespace()+ let myline=line(".")+ let mycolumn = col(".")+ silent %s/ *$//+ call cursor(myline, mycolumn)+endfunction++" enable syntax highlighting+syntax on++" search for the tags file anywhere between here and /+set tags=TAGS;/++" highlight tabs and trailing spaces+set listchars=tab:‗‗,trail:‗+set list++" f2 runs hasktags+map <F2> :exec ":!hasktags -x -c --ignore src"<CR><CR>++" strip trailing whitespace before saving+" au BufWritePre *.hs,*.markdown silent! cal StripTrailingWhitespace()++" rebuild hasktags after saving+au BufWritePost *.hs silent! :exec ":!hasktags -x -c --ignore src"
CHANGELOG.markdown view
@@ -1,3 +1,9 @@+0.6+---+* `instance Exception Void`+* `instance Generic Void`+* `instance Hashable Void`+ 0.5.12 ------ * Fixed compatibility with GHC 7.2 (#6)
− Data/Void.hs
@@ -1,76 +0,0 @@-{-# LANGUAGE CPP #-}--------------------------------------------------------------------------------- |--- Module : Data.Void--- Copyright : (C) 2008-2011 Edward Kmett--- License : BSD-style (see the file LICENSE)------ Maintainer : Edward Kmett <ekmett@gmail.com>--- Stability : provisional--- Portability : portable---------------------------------------------------------------------------------module Data.Void- ( Void- , absurd- , vacuous- , vacuousM- ) where--import Data.Ix-import Control.Monad (liftM)-import Data.Semigroup (Semigroup(..))--#ifdef LANGUAGE_DeriveDataTypeable-import Data.Data-#endif---- | A logically uninhabited data type.-#if __GLASGOW_HASKELL__ < 700-data Void = Void !Void-#else-newtype Void = Void Void-#endif-#ifdef LANGUAGE_DeriveDataTypeable- deriving (Data, Typeable)-#endif--instance Eq Void where- _ == _ = True--instance Ord Void where- compare _ _ = EQ--instance Show Void where- showsPrec _ = absurd---- | Reading a 'Void' value is always a parse error, considering 'Void' as--- a data type with no constructors.-instance Read Void where- readsPrec _ _ = []---- | Since 'Void' values logically don't exist, this witnesses the logical--- reasoning tool of \"ex falso quodlibet\".-absurd :: Void -> a-absurd a = a `seq` spin a where- spin (Void b) = spin b---- | If 'Void' is uninhabited then any 'Functor' that holds only values of type 'Void'--- is holding no values.-vacuous :: Functor f => f Void -> f a-vacuous = fmap absurd---- | If 'Void' is uninhabited then any 'Monad' that holds values of type 'Void'--- is holding no values.-vacuousM :: Monad m => m Void -> m a-vacuousM = liftM absurd--instance Semigroup Void where- a <> _ = a- times1p _ a = a--instance Ix Void where- range _ = []- index _ = absurd- inRange _ = absurd- rangeSize _ = 0
− Data/Void/Unsafe.hs
@@ -1,48 +0,0 @@-{-# LANGUAGE CPP #-}-#if !defined(SAFE) && defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 704-#define UNSAFE-{-# LANGUAGE Unsafe #-}-#endif--------------------------------------------------------------------------------- |--- Module : Data.Void.Unsafe--- Copyright : (C) 2008-2012 Edward Kmett--- License : BSD-style (see the file LICENSE)------ Maintainer : Edward Kmett <ekmett@gmail.com>--- Stability : provisional--- Portability : portable---------------------------------------------------------------------------------module Data.Void.Unsafe- ( unsafeVacuous- , unsafeVacuousM- ) where--import Data.Void--#ifdef UNSAFE-import Unsafe.Coerce-#endif---- | If 'Void' is uninhabited than any 'Functor' that holds only values of the type 'Void'--- is holding no values.------ This is only safe for valid functors that do not perform GADT-like analysis on the argument.-unsafeVacuous :: Functor f => f Void -> f a-#ifdef UNSAFE-unsafeVacuous = unsafeCoerce-#else-unsafeVacuous = fmap absurd-#endif---- | If 'Void' is uninhabited then any 'Monad' that holds values of type 'Void'--- is holding no values.------ This is only safe for valid monads that do not perform GADT-like analysis on the argument.-unsafeVacuousM :: Monad m => m Void -> m a-#ifdef UNSAFE-unsafeVacuousM = unsafeCoerce-#else-unsafeVacuousM m = m >>= return . absurd-#endif
LICENSE view
@@ -1,4 +1,4 @@-Copyright 2011 Edward Kmett+Copyright 2013 Edward Kmett All rights reserved.
+ src/Data/Void.hs view
@@ -0,0 +1,108 @@+{-# LANGUAGE CPP #-}++#ifdef LANGUAGE_DeriveDataTypeable+{-# LANGUAGE DeriveDataTypeable #-}+#endif++#ifdef LANGUAGE_DeriveGeneric+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE StandaloneDeriving #-}+#endif++#ifndef MIN_VERSION_base+#define MIN_VERSION_base(x,y,z) 1+#endif+-----------------------------------------------------------------------------+-- |+-- Copyright : (C) 2008-2013 Edward Kmett+-- License : BSD-style (see the file LICENSE)+--+-- Maintainer : Edward Kmett <ekmett@gmail.com>+-- Stability : provisional+-- Portability : portable+--+----------------------------------------------------------------------------+module Data.Void+ ( Void+ , absurd+ , vacuous+ , vacuousM+ ) where++import Control.Monad (liftM)+import Data.Ix+import Data.Hashable+import Data.Semigroup (Semigroup(..))++#ifdef LANGUAGE_DeriveDataTypeable+import Data.Data+#endif++#ifdef LANGUAGE_DeriveGeneric+import GHC.Generics+#endif++#if MIN_VERSION_base(4,0,0)+import Control.Exception+#endif++-- | A logically uninhabited data type.+#if __GLASGOW_HASKELL__ < 700+data Void = Void !Void+#else+newtype Void = Void Void+#endif+#ifdef LANGUAGE_DeriveDataTypeable+ deriving (Data, Typeable)+#endif++#ifdef LANGUAGE_DeriveGeneric+deriving instance Generic Void+#endif++instance Eq Void where+ _ == _ = True++instance Hashable Void where+ hashWithSalt _ = absurd++instance Ord Void where+ compare _ _ = EQ++instance Show Void where+ showsPrec _ = absurd++-- | Reading a 'Void' value is always a parse error, considering 'Void' as+-- a data type with no constructors.+instance Read Void where+ readsPrec _ _ = []++-- | Since 'Void' values logically don't exist, this witnesses the logical+-- reasoning tool of \"ex falso quodlibet\".+absurd :: Void -> a+absurd a = a `seq` spin a where+ spin (Void b) = spin b++-- | If 'Void' is uninhabited then any 'Functor' that holds only values of type 'Void'+-- is holding no values.+vacuous :: Functor f => f Void -> f a+vacuous = fmap absurd++-- | If 'Void' is uninhabited then any 'Monad' that holds values of type 'Void'+-- is holding no values.+vacuousM :: Monad m => m Void -> m a+vacuousM = liftM absurd++instance Semigroup Void where+ a <> _ = a+ times1p _ a = a++instance Ix Void where+ range _ = []+ index _ = absurd+ inRange _ = absurd+ rangeSize _ = 0++#if MIN_VERSION_base(4,0,0)+instance Exception Void+#endif
+ src/Data/Void/Unsafe.hs view
@@ -0,0 +1,47 @@+{-# LANGUAGE CPP #-}+#if !defined(SAFE) && defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 704+#define UNSAFE+{-# LANGUAGE Unsafe #-}+#endif+-----------------------------------------------------------------------------+-- |+-- Copyright : (C) 2008-2013 Edward Kmett+-- License : BSD-style (see the file LICENSE)+--+-- Maintainer : Edward Kmett <ekmett@gmail.com>+-- Stability : provisional+-- Portability : portable+--+----------------------------------------------------------------------------+module Data.Void.Unsafe+ ( unsafeVacuous+ , unsafeVacuousM+ ) where++import Data.Void++#ifdef UNSAFE+import Unsafe.Coerce+#endif++-- | If 'Void' is uninhabited than any 'Functor' that holds only values of the type 'Void'+-- is holding no values.+--+-- This is only safe for valid functors that do not perform GADT-like analysis on the argument.+unsafeVacuous :: Functor f => f Void -> f a+#ifdef UNSAFE+unsafeVacuous = unsafeCoerce+#else+unsafeVacuous = fmap absurd+#endif++-- | If 'Void' is uninhabited then any 'Monad' that holds values of type 'Void'+-- is holding no values.+--+-- This is only safe for valid monads that do not perform GADT-like analysis on the argument.+unsafeVacuousM :: Monad m => m Void -> m a+#ifdef UNSAFE+unsafeVacuousM = unsafeCoerce+#else+unsafeVacuousM m = m >>= return . absurd+#endif
void.cabal view
@@ -1,6 +1,6 @@ name: void category: Data Structures-version: 0.5.12+version: 0.6 license: BSD3 cabal-version: >= 1.6 license-file: LICENSE@@ -9,12 +9,18 @@ stability: portable homepage: http://github.com/ekmett/void bug-reports: http://github.com/ekmett/void/issues-copyright: Copyright (C) 2008-2012 Edward A. Kmett+copyright: Copyright (C) 2008-2013 Edward A. Kmett synopsis: A Haskell 98 logically uninhabited data type description: A Haskell 98 logically uninhabited data type, used to indicate that a given term should not exist. build-type: Simple -extra-source-files: .travis.yml CHANGELOG.markdown README.markdown+extra-source-files:+ .ghci+ .gitignore+ .travis.yml+ .vim.custom+ CHANGELOG.markdown+ README.markdown source-repository head type: git@@ -25,12 +31,14 @@ default: False library+ hs-source-dirs: src exposed-modules: Data.Void Data.Void.Unsafe build-depends: base >= 3 && < 10,+ hashable >= 1.1, semigroups >= 0.8.2 ghc-options: -Wall@@ -39,5 +47,11 @@ cpp-options: -DSAFE if impl(ghc)- extensions: DeriveDataTypeable+ other-extensions: DeriveDataTypeable cpp-options: -DLANGUAGE_DeriveDataTypeable++ if impl(ghc >= 7.2)+ other-extensions: StandaloneDeriving+ -- other-extensions: DeriveGeneric isn't known to cabal yet+ cpp-options: -DLANGUAGE_DeriveGeneric+ build-depends: ghc-prim