packages feed

sourcemap 0.1.6 → 0.1.6.1

raw patch · 6 files changed

+46/−35 lines, 6 filesnew-uploader

Files

bench/Bench/VLQ.hs view
@@ -13,8 +13,8 @@ main = do   defaultMain [benchmark]   where benchmark = bgroup "numbers"-                           (map (\n -> bench (show n) (whnf encode n))-                                (map (fromIntegral :: Int -> Int32)-                                     (take 5-                                           (randomRs (1000000000,2000000000)-                                                     (mkStdGen 1)))))+                           (map ((\n -> bench (show n) (whnf encode n)) .+                                 (fromIntegral :: Int -> Int32))+                             (take 5+                               (randomRs (1000000000,2000000000)+                                 (mkStdGen 1))))
sourcemap.cabal view
@@ -1,5 +1,5 @@ name:                sourcemap-version:             0.1.6+version:             0.1.6.1 synopsis:            Implementation of source maps as proposed by Google and Mozilla. description:         Implementation of source maps, revision 3, proposed by Google and Mozilla here                      <https://wiki.mozilla.org/DevTools/Features/SourceMap> and here@@ -8,19 +8,25 @@ license-file:        LICENSE author:              Chris Done stability:           alpha-maintainer:          chrisdone@gmail.com+maintainer:          Jens Petersen <juhpetersen@gmail.com>+bug-reports:         https://github.com/juhp/sourcemap/issues copyright:           2012 Chris Done category:            Development build-type:          Simple-cabal-version:       >=1.8+cabal-version:       >=1.10 +source-repository head+    type:     git+    location: https://github.com/juhp/sourcemap.git+ library-  ghc-options: -O2 -Wall+  default-language:    Haskell2010+  ghc-options: -Wall   exposed-modules:     SourceMap, SourceMap.Types   other-modules:       VLQ   hs-source-dirs:      src-  build-depends:       base >= 4 && < 5,-                       bytestring,+  build-depends:       base >= 4.5 && < 5,+                       bytestring >= 0.10.2 && < 0.11,                        aeson,                        unordered-containers,                        attoparsec,@@ -30,8 +36,10 @@   test-suite nodejs+    default-language: Haskell2010     type:       exitcode-stdio-1.0     main-is:    Node.hs+    other-modules: SourceMap, SourceMap.Types, VLQ     hs-source-dirs: src test     build-depends: base,                    sourcemap,@@ -43,11 +51,13 @@                    unordered-containers  benchmark vlq+  default-language: Haskell2010   type:             exitcode-stdio-1.0   hs-source-dirs:   src bench   main-is:          Bench/VLQ.hs+  other-modules:       VLQ   build-depends:    base,                     criterion,                     bytestring,                     random-  ghc-options:      -O2 -Wall+  ghc-options:      -Wall
src/SourceMap.hs view
@@ -1,13 +1,13 @@-{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-}-{-# OPTIONS -Wall #-}+{-# LANGUAGE RecordWildCards #-}  -- | Generate JSON from a source mapping.  module SourceMap (generate) where  import           SourceMap.Types-import qualified VLQ as VLQ+import qualified VLQ  import           Control.Monad hiding (forM_) import           Control.Monad.ST@@ -18,7 +18,9 @@ import           Data.ByteString.Builder (Builder(), lazyByteString, toLazyByteString) import           Data.Foldable (forM_) import qualified Data.HashMap.Lazy as Map-import           Data.Monoid+#if !MIN_VERSION_base(4,11,0)+import Data.Monoid ((<>))+#endif import           Data.List import           Data.Maybe import           Data.Ord@@ -62,7 +64,7 @@                                              (fromIntegral (fromEnum ';'))                    return (posLine mapGenerated)            else do when (i > 0)-                        (result += (fromString ","))+                        (result += fromString ",")                    return previousGeneratedLine       -- Original generated column (also offsetted from previous entries).       updating prevGenCol $ \previousGeneratedColumn -> do@@ -90,9 +92,9 @@              result += VLQ.encode (indexOf name names - previousName)              return (indexOf name names)     -- Return the byte buffer.-    fmap toLazyByteString $ readSTRef result+    toLazyByteString <$> readSTRef result -  updating r f = readSTRef r >>= \x -> f x >>= writeSTRef r+  updating r f = readSTRef r >>= (f >=> writeSTRef r)   r += y = modifySTRef r (<> lazyByteString y)   x .= y = writeSTRef x y; infixr 1 .=   indexOf e xs = fromIntegral (fromMaybe 0 (elemIndex e xs))
src/SourceMap/Types.hs view
@@ -1,11 +1,13 @@-{-# OPTIONS -Wall #-}+{-# LANGUAGE CPP #-}  -- | Types for the source maps.  module SourceMap.Types where  import Data.Int-import Data.Monoid+#if !MIN_VERSION_base(4,11,0)+import Data.Monoid ((<>))+#endif import Data.Text import Data.Function 
src/VLQ.hs view
@@ -3,8 +3,6 @@ -- https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java -- -{-# OPTIONS -Wall #-}- module VLQ   (encode   ,decode)@@ -15,6 +13,7 @@ import qualified Data.ByteString.Lazy as B import           Data.Int import           Data.List+import           Data.Maybe import           Data.Word import           Prelude hiding ((>>)) @@ -98,15 +97,13 @@  -- | Encode the given number to a base 64 character. encodeBase64 :: Word8 -> Word8-encodeBase64 i = maybe (error "Base 64 char must be between 0 and 63.")-                       id-                       (lookup i (zip [0..] base64Chars))+encodeBase64 i = fromMaybe (error "Base 64 char must be between 0 and 63.")+                 (lookup i (zip [0..] base64Chars))  -- | Encode the given base 64 character to a number. decodeBase64 :: Word8 -> Word8-decodeBase64 i = maybe (error "Not a valid base 65 digit.")-                       id-                        (lookup i (zip base64Chars [0..]))+decodeBase64 i = fromMaybe (error "Not a valid base 65 digit.")+                 (lookup i (zip base64Chars [0..]))  -- | Makes the code more familiar to read. Shift-left. (<<) :: Int32 -> Int -> Int32
test/Node.hs view
@@ -16,7 +16,7 @@ import qualified Data.ByteString.Lazy.UTF8 as Bytes import           Data.List import           System.Exit-import           System.Process.Extra+import           System.Process  -- | Run the test suite. main :: IO ()@@ -34,17 +34,17 @@   let !h = generate m   if h == n      then exitSuccess-     else do putStr $ "Node:    "; Bytes.putStrLn $ encode n+     else do putStr "Node:    "; Bytes.putStrLn $ encode n              putStr "Haskell: "; Bytes.putStrLn $ encode h              exitFailure  -- | Generate a source map using the nodejs source-map package. generateNode :: SourceMapping -> IO Value generateNode SourceMapping{..} = do-  result <- readAllFromProcess' "node" [] source-  case result of-    Left err -> error err-    Right (_err,out) ->+  (ret, out, err) <- readProcessWithExitCode "node" [] source+  if ret /= ExitSuccess+    then error err+    else       case decode (Bytes.fromString (concat (lines out))) of          Just value -> return value          Nothing    -> error "unable to parse node's json output"