packages feed

bool8 (empty) → 0.0

raw patch · 4 files changed

+119/−0 lines, 4 filesdep +basesetup-changed

Dependencies added: base

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2017, Henning Thielemann++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 Henning Thielemann 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.
+ Setup.lhs view
@@ -0,0 +1,8 @@+#!/usr/bin/env runghc++> module Main where++> import Distribution.Simple++> main :: IO ()+> main = defaultMain
+ bool8.cabal view
@@ -0,0 +1,37 @@+Name:                bool8+Version:             0.0+Synopsis:            Alternative Bool type stored as byte+Description:+  The standard 'Bool' type has a 'Storable' instance+  that requires the size of @HTYPE_INT@,+  i.e. usually four bytes or even more.+  This package provides 'Bool8',+  a boolean type with an 8 bit representation in memory.+  It is not a drop-in replacement for 'Bool' though.+  You have to convert from or to 'Bool' occasionally.+License:             BSD3+License-File:        LICENSE+Author:              Henning Thielemann+Maintainer:          haskell@henning-thielemann.de+Category:            Foreign+Stability:           Stable+Build-Type:          Simple+Cabal-Version:       >=1.10+Tested-With:         GHC==7.4.2, GHC==7.6.3, GHC==7.8.4, GHC==7.10.3+Tested-With:         GHC==8.0.2, GHC==8.2.2++Source-Repository this+  Tag:         0.0+  Type:        darcs+  Location:    http://hub.darcs.net/thielema/bool8++Source-Repository head+  Type:        darcs+  Location:    http://hub.darcs.net/thielema/bool8++Library+  Exposed-Modules:     Data.Bool8+  Build-Depends:       base >=3 && <5+  Hs-Source-Dirs:      src+  Default-Language:    Haskell98+  GHC-Options:         -Wall
+ src/Data/Bool8.hs view
@@ -0,0 +1,44 @@+module Data.Bool8 (+   Bool8,+   false, true,+   toBool,+   fromBool,+   ) where++import Foreign.Storable (Storable, poke, peek, sizeOf, alignment)+import Foreign.Ptr (castPtr)++import Data.Functor ((<$>))+import Data.Word (Word8)+++newtype Bool8 = Bool8 Word8+   deriving (Eq, Ord)++instance Show Bool8 where+   show (Bool8 0) = "Bool8.false"+   show _ = "Bool8.true"++instance Bounded Bool8 where+   minBound = false+   maxBound = true++instance Storable Bool8 where+   sizeOf _ = 1+   alignment _ = 1+   peek ptr = Bool8 <$> peek (castPtr ptr)+   poke ptr (Bool8 b) = poke (castPtr ptr) b++instance Enum Bool8 where+   fromEnum (Bool8 b) = fromIntegral b+   toEnum k = Bool8 $ if k==0 then 0 else 1++false, true :: Bool8+false = Bool8 0+true = Bool8 1++toBool :: Bool8 -> Bool+toBool (Bool8 b) = b/=0++fromBool :: Bool -> Bool8+fromBool b = if b then true else false