Compare commits

...

4 Commits

Author SHA1 Message Date
Gregor Kleen
22fc3bb148 Fix arithmetic for ghc8.8.2 2020-02-22 20:47:54 +01:00
Gregor Kleen
00270d4bc7 Bump stack 2019-09-23 15:38:10 +02:00
Gregor Kleen
f07769687b Bump Cabal 2018-09-14 20:37:16 +02:00
Gregor Kleen
67bb87ceff Relax upper version bounds on dependencies 2018-02-20 17:46:24 +01:00
5 changed files with 64 additions and 31 deletions

View File

@ -9,8 +9,8 @@ import Data.Bits
buildStaticMap :: (StaticElement i,StaticElement e,Ord i) => [(i,e)] -> String buildStaticMap :: (StaticElement i,StaticElement e,Ord i) => [(i,e)] -> String
buildStaticMap lst = let step :: Int -> [(i,e)] -> [(Int,(i,e))] buildStaticMap lst = let step :: Int -> [(i,e)] -> [(Int,(i,e))]
step n chunk = let ss = findSplitSize (length chunk) step n chunk = let ss = findSplitSize (genericLength chunk)
(h,d:t) = splitAt ss chunk (h,d:t) = genericSplitAt ss chunk
in if null chunk in if null chunk
then [] then []
else (n,d):((step (n*2) h)++(step (n*2+1) t)) else (n,d):((step (n*2) h)++(step (n*2+1) t))
@ -24,19 +24,19 @@ buildStaticMap lst = let step :: Int -> [(i,e)] -> [(Int,(i,e))]
len = length heap len = length heap
in "StaticMap ("++buildStaticArray (1,len) (map fst heap)++") ("++buildStaticArray (1,len) (map snd heap)++")" in "StaticMap ("++buildStaticArray (1,len) (map fst heap)++") ("++buildStaticArray (1,len) (map snd heap)++")"
maxSize :: Int -> Int maxSize :: Integer -> Integer
maxSize d = (1 `shiftL` d) - 1 maxSize d = (floor $ 2^^d) - 1
treeDepth :: Int -> Int treeDepth :: Integer -> Integer
treeDepth sz = find' [0..] treeDepth sz = find' [0..]
where where
find' (x:xs) = if 1 `shiftL` x > sz find' (x:xs) = if (floor $ 2^^x) > sz
then x then x
else find' xs else find' xs
findSplitSize :: Int -> Int findSplitSize :: Integer -> Integer
findSplitSize len = let depth = treeDepth len findSplitSize len = let depth = treeDepth len
free = (maxSize depth) - len free = (maxSize depth) - len
in if free <= (1 `shiftL` (depth - 2)) in if free <= (floor $ 2 ^^ (depth - 2))
then maxSize (depth - 1) then maxSize (depth - 1)
else len - (maxSize (depth - 2)) - 1 else len - (maxSize (depth - 2)) - 1

View File

@ -1,9 +1,20 @@
{-# LANGUAGE CPP #-}
module Main where module Main where
import Distribution.Simple import Distribution.Simple
import Data.Encoding.Preprocessor.Mapping import Data.Encoding.Preprocessor.Mapping
import Data.Encoding.Preprocessor.XMLMappingBuilder import Data.Encoding.Preprocessor.XMLMappingBuilder
#if MIN_VERSION_Cabal(2,0,0)
main = defaultMainWithHooks (simpleUserHooks
{hookedPreProcessors = ( ("mapping" , \_ _ _ -> mappingPreprocessor)
: ("mapping2", \_ _ _ -> mappingPreprocessor)
: ("xml" , \_ _ _ -> xmlPreprocessor)
: (hookedPreProcessors simpleUserHooks)
)
})
#else
main = defaultMainWithHooks (simpleUserHooks main = defaultMainWithHooks (simpleUserHooks
{hookedPreProcessors = ( ("mapping" , \_ _ -> mappingPreprocessor) {hookedPreProcessors = ( ("mapping" , \_ _ -> mappingPreprocessor)
: ("mapping2", \_ _ -> mappingPreprocessor) : ("mapping2", \_ _ -> mappingPreprocessor)
@ -11,3 +22,4 @@ main = defaultMainWithHooks (simpleUserHooks
: (hookedPreProcessors simpleUserHooks) : (hookedPreProcessors simpleUserHooks)
) )
}) })
#endif

View File

@ -36,22 +36,23 @@ Source-Repository this
Custom-Setup Custom-Setup
Setup-Depends: base >=3 && <5, Setup-Depends: base >=3 && <5,
Cabal >=1.24 && <1.25, Cabal >=1.24 && <4,
containers, containers,
filepath, filepath,
ghc-prim, ghc-prim,
HaXml >=1.22 && <1.26 HaXml >=1.22 && <1.26,
deepseq
Library Library
Build-Depends: array >=0.4 && <0.6, Build-Depends: array >=0.4 && <0.6,
base >=4 && <5, base >=4 && <5,
binary >=0.7 && <0.10, binary >=0.7 && <0.10,
bytestring >=0.9 && <0.11, bytestring >=0.9 && <0.11,
containers >=0.4 && <0.6, containers >=0.4 && <0.7,
extensible-exceptions >=0.1 && <0.2, extensible-exceptions >=0.1 && <0.2,
ghc-prim >=0.3 && <0.6, ghc-prim >=0.3 && <0.6,
mtl >=2.0 && <2.3, mtl >=2.0 && <2.3,
regex-compat >=0.71 && <0.95 regex-compat >=0.71 && <0.96
Extensions: CPP Extensions: CPP

View File

@ -15,7 +15,7 @@
# resolver: # resolver:
# name: custom-snapshot # name: custom-snapshot
# location: "./custom-snapshot.yaml" # location: "./custom-snapshot.yaml"
resolver: lts-8.22 resolver: lts-15.0
# User packages to be built. # User packages to be built.
# Various formats can be used as shown in the example below. # Various formats can be used as shown in the example below.
@ -39,7 +39,8 @@ packages:
- '.' - '.'
# Dependency packages to be pulled from upstream that are not in the resolver # Dependency packages to be pulled from upstream that are not in the resolver
# (e.g., acme-missiles-0.3) # (e.g., acme-missiles-0.3)
extra-deps: [] extra-deps:
- HaXml-1.25.5
# Override default flag values for local packages and extra-deps # Override default flag values for local packages and extra-deps
flags: {} flags: {}

19
stack.yaml.lock Normal file
View File

@ -0,0 +1,19 @@
# This file was autogenerated by Stack.
# You should not edit this file by hand.
# For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files
packages:
- completed:
hackage: HaXml-1.25.5@sha256:4f8534cda290b3d0a76b4ca5c4b9aa20902dcf029ddd50998d07c5dd608ad6f6,4420
pantry-tree:
size: 4076
sha256: 9682020b148433c41f5efee327b66708875015df8d4b3d48f875ac21f8222e1b
original:
hackage: HaXml-1.25.5
snapshots:
- completed:
size: 488576
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/15/0.yaml
sha256: e4b6a87b47ec1cf63a7f1a0884a3b276fce2b0d174a10e8753c4f618e7983568
original: lts-15.0