[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36

John Goerzen jgoerzen at complete.org
Fri Apr 23 15:03:31 UTC 2010


The following commit has been merged in the master branch:
commit ae1e8cae5bca40daf4b32d8ddfad13e242c4813b
Author: John Goerzen <jgoerzen at complete.org>
Date:   Mon Oct 10 22:07:57 2005 +0100

    Added Word8 conversion functions

diff --git a/MissingH/Bits.hs b/MissingH/Bits.hs
index 112278d..36605cb 100644
--- a/MissingH/Bits.hs
+++ b/MissingH/Bits.hs
@@ -1,5 +1,5 @@
 {- arch-tag: Bit utilities main file
-Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
+Copyright (C) 2004-2005 John Goerzen <jgoerzen at complete.org>
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 {- |
    Module     : MissingH.Bits
-   Copyright  : Copyright (C) 2004 John Goerzen
+   Copyright  : Copyright (C) 2004-2005 John Goerzen
    License    : GNU GPL, version 2 or above
 
    Maintainer : John Goerzen <jgoerzen at complete.org> 
@@ -30,9 +30,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 Written by John Goerzen, jgoerzen\@complete.org
 -}
 
-module MissingH.Bits(getBytes, fromBytes)
+module MissingH.Bits(getBytes, fromBytes,
+                     c2w8, s2w8, w82c, w82s)
 where
 import Data.Bits
+import Data.Word
 
 {- | Returns a list representing the bytes that comprise a data type.
 
@@ -62,3 +64,19 @@ fromBytes input =
         dofb accum (x:xs) = dofb ((shiftL accum 8) .|. x) xs
         in
         dofb 0 input
+
+{- | Converts a Char to a Word8. -}
+c2w8 :: Char -> Word8
+c2w8 = fromIntegral . fromEnum
+
+{- | Converts a String to a [Word8]. -}
+s2w8 :: String -> [Word8]
+s2w8 = map c2w8
+
+{- | Converts a Word8 to a Char. -}
+w82c :: Word8 -> Char
+w82c = toEnum . fromIntegral
+
+{- | Converts a [Word8] to a String. -}
+w82s :: [Word8] -> String
+w82s = map w82c

-- 
haskell-testpack



More information about the Pkg-haskell-commits mailing list