foundation-edge 0.0.1 → 0.0.2
raw patch · 4 files changed
+43/−7 lines, 4 filesdep +textdep −basedep ~foundationPVP ok
version bump matches the API change (PVP)
Dependencies added: text
Dependencies removed: base
Dependency ranges changed: foundation
API changes (from Hackage documentation)
+ Foundation.Compat.ByteString: toByteString :: UArray Word8 -> ByteString
+ Foundation.Compat.Text: fromText :: Text -> String
+ Foundation.Compat.Text: toText :: String -> Text
Files
- Foundation/Compat/ByteString.hs +11/−2
- Foundation/Compat/Text.hs +26/−0
- README.md +2/−2
- foundation-edge.cabal +4/−3
Foundation/Compat/ByteString.hs view
@@ -9,15 +9,24 @@ {-# LANGUAGE ViewPatterns #-} module Foundation.Compat.ByteString ( fromByteString+ , toByteString ) where import Data.ByteString (ByteString)-import Data.ByteString.Internal (toForeignPtr)+import Data.ByteString.Internal (toForeignPtr, unsafeCreate, memcpy) import Foundation import Foundation.Array-import Foundation.Array.Internal+import Foundation.Array.Internal (withPtr, fromForeignPtr) -- | Convert a ByteString to a UArray Word8, -- without re-allocating or copying anything fromByteString :: ByteString -> UArray Word8 fromByteString = fromForeignPtr . toForeignPtr++-- | Convert a UArray Word8 to ByteString+--+-- all the bytes are copied to a brand new memory chunk+toByteString :: UArray Word8 -> ByteString+toByteString v = unsafeCreate len $ \dst -> withPtr v $ \src -> memcpy dst src len+ where+ !len = length v
+ Foundation/Compat/Text.hs view
@@ -0,0 +1,26 @@+-- |+-- Module : Foundation.Compat.Text+-- License : BSD-style+-- Maintainer : Foundation+-- Stability : experimental+-- Portability : portable+--+-- Module to convert text's Text type+module Foundation.Compat.Text+ ( toText+ , fromText+ ) where++import Data.Text (Text)+import qualified Data.Text as T+import Foundation++-- | Convert a String to a Text.+-- This currently allocates a new Text and copies the String content.+toText :: String -> Text+toText = T.pack . toList++-- | Convert a Text to String+-- This currently allocates a new String and copies the Text content.+fromText :: Text -> String+fromText = fromList . T.unpack
README.md view
@@ -6,11 +6,11 @@ For now, edge support the following packages: -* bytestring (incomplete)+* bytestring (initial)+* text (initial) And planning to add support to: -* text * vector If you think edge would benefits from other packages, open an issue (or even better a PR) with
foundation-edge.cabal view
@@ -1,5 +1,5 @@ Name: foundation-edge-Version: 0.0.1+Version: 0.0.2 Synopsis: foundation's edge with the conventional set of packages Description: A set of functions to allow interaction with more conventional@@ -28,12 +28,13 @@ Library Exposed-modules: Foundation.Compat.ByteString+ , Foundation.Compat.Text Default-Extensions: NoImplicitPrelude TypeFamilies BangPatterns DeriveDataTypeable- Build-depends: base >= 4 && < 5- , foundation+ Build-depends: foundation >= 0.0.7 , bytestring+ , text ghc-options: -Wall default-language: Haskell2010