snow-white (empty) → 2009.12.1
raw patch · 6 files changed
+246/−0 lines, 6 filesdep +basedep +binarydep +bytestringsetup-changed
Dependencies added: base, binary, bytestring, mps
Files
- LICENSE +31/−0
- Setup.lhs +4/−0
- changelog.md +135/−0
- readme.md +12/−0
- snow-white.cabal +31/−0
- src/Codec/SnowWhite.hs +33/−0
+ LICENSE view
@@ -0,0 +1,31 @@+Copyright (c) 2009, Jinjing Wang++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 Jinjing Wang 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,4 @@+#! /usr/bin/env runhaskell++> import Distribution.Simple+> main = defaultMain
+ changelog.md view
@@ -0,0 +1,135 @@+2009.10.30+----------++### Feature++* add remoteHost field++2009.7.15+---------++### Feature++* new hackCache header using strict bytestrings++2009.5.19+---------++### Feature++* Use lazy bytestring for performance and hinting utf-8 encoding+* remove some unused fields+* use haskell naming convention++2009.4.52+---------++### Feature++* Remove useless type alias++### Fix++* Default error stream should take utf8 string+++2009.4.51+---------++### Feature++* add documentation++2009.4.50+---------++### Feature++* add version info in default++2009.4.30+----------++### Feature++* seperate handler from core module+* seperate contrib from Hack.hs+* now Hack.hs is only an interface file, where everything links to. This allows me to soft link handler in Hack.Contrib and Hack.Handler in development mode :)++2009.4.29+-----------++### Fix++* -Wall clean+++2009.4.28+-----------++### Fix++* File return status code 200 on success++2009.4.27+---------++### Fix++* hyena handler show real message ( Safari won't work without this fix )++2009.4.26+---------++### Fix++* add hyena handler++2009.4.25+---------++### Featuer++* more middleware+* hyena handler for simple use server++2009.4.23+---------++### Feature++* more middleware+ * ContentSize+ * SimpleAccessLogger++* request helper++2009.4.22+---------++### Feature++* more middleware+ * ContentType+ * RawRouter+ * SimpleRouter++2009.4.21+------------++### Feature++* demo SimpleRoute middleware++### Fix++* env for kibro adapter+* homepage in hack.cabal++2009.4.20+-----------++### Feature++* raw specification+* shiny kibro hack handler
+ readme.md view
@@ -0,0 +1,12 @@+Snow White+==========++encode any binary instance to white space++example++ SnowWhite.pack "hello"+ > + + SnowWhite.unpack " "+ > hello
+ snow-white.cabal view
@@ -0,0 +1,31 @@+Name: snow-white+Version: 2009.12.1+Build-type: Simple+Synopsis: encode any binary instance to white space+Description:++ SnowWhite.pack "hello"++ > +++ SnowWhite.unpack " "++ > hello++License: BSD3+License-file: LICENSE+Author: Wang, Jinjing+Maintainer: Wang, Jinjing <nfjinjing@gmail.com>+Build-Depends: base+Cabal-version: >= 1.2+category: Codec+homepage: http://github.com/nfjinjing/snow-white+data-files: readme.md, changelog.md++library+ ghc-options: -Wall+ build-depends: base >= 4 && < 5, mps, bytestring, binary+ hs-source-dirs: src/+ exposed-modules: + Codec.SnowWhite
+ src/Codec/SnowWhite.hs view
@@ -0,0 +1,33 @@+module Codec.SnowWhite (pack, unpack) where++import Data.Binary+import Numeric+import MPS.Env hiding (encode, decode)+import Prelude ()+import qualified Data.ByteString.Lazy.Char8 as B+import Data.Char++c2w, w2c :: Char -> Char+c2w '0' = ' '+c2w '1' = '\t'+c2w _ = error "not 0 or 1"++w2c ' ' = '0'+w2c '\t' = '1'+w2c _ = error "not 0 or 1"++b2s, pack :: (Binary a) => a -> String+b2s = encode > B.unpack > map (ord > (base 2) > rjust 8 '0' > map c2w) > concat++base :: Int -> Int -> String+base p n = showIntAtBase p intToDigit n ""++from_base :: Int -> String -> Int+from_base p = readInt p (const True) digitToInt > first > fst++s2b, unpack :: (Binary a) => String -> a+s2b = select (belongs_to " \t") > in_group_of 8 > map (map w2c > from_base 2 > chr) > B.pack > decode+++pack = b2s+unpack = s2b