dependency bump & fourmolu
This commit is contained in:
parent
110c6eb8a5
commit
5bb8afb672
5 changed files with 54 additions and 39 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -3,3 +3,5 @@
|
||||||
/.direnv/
|
/.direnv/
|
||||||
**/.DS_Store
|
**/.DS_Store
|
||||||
/cabal.project.local
|
/cabal.project.local
|
||||||
|
/compress.hp
|
||||||
|
/*.prof
|
||||||
|
|
|
||||||
30
flake.lock
generated
30
flake.lock
generated
|
|
@ -5,11 +5,11 @@
|
||||||
"nixpkgs-lib": "nixpkgs-lib"
|
"nixpkgs-lib": "nixpkgs-lib"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1709336216,
|
"lastModified": 1712014858,
|
||||||
"narHash": "sha256-Dt/wOWeW6Sqm11Yh+2+t0dfEWxoMxGBvv3JpIocFl9E=",
|
"narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=",
|
||||||
"owner": "hercules-ci",
|
"owner": "hercules-ci",
|
||||||
"repo": "flake-parts",
|
"repo": "flake-parts",
|
||||||
"rev": "f7b3c975cf067e56e7cda6cb098ebe3fb4d74ca2",
|
"rev": "9126214d0a59633752a136528f5f3b9aa8565b7d",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -20,11 +20,11 @@
|
||||||
},
|
},
|
||||||
"haskell-flake": {
|
"haskell-flake": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1711149116,
|
"lastModified": 1713084600,
|
||||||
"narHash": "sha256-tccTtjRvxrhSJkCnmNwaPrq0DDM3UsM0uiDyW4uJXXc=",
|
"narHash": "sha256-qL7LV2MtwJ+1Xasg1TjSUmoE7yrRuXPqxpPlKjLE0SE=",
|
||||||
"owner": "srid",
|
"owner": "srid",
|
||||||
"repo": "haskell-flake",
|
"repo": "haskell-flake",
|
||||||
"rev": "6ae8a85071adfe08d70d9963c526947403c6c070",
|
"rev": "847292fc793a5c15c873e52e7751ee4267ef32a0",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -35,11 +35,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1711163522,
|
"lastModified": 1712963716,
|
||||||
"narHash": "sha256-YN/Ciidm+A0fmJPWlHBGvVkcarYWSC+s3NTPk/P+q3c=",
|
"narHash": "sha256-WKm9CvgCldeIVvRz87iOMi8CFVB1apJlkUT4GGvA0iM=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "44d0940ea560dee511026a53f0e2e2cde489b4d4",
|
"rev": "cfd6b5fc90b15709b780a5a1619695a88505a176",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -52,11 +52,11 @@
|
||||||
"nixpkgs-lib": {
|
"nixpkgs-lib": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"dir": "lib",
|
"dir": "lib",
|
||||||
"lastModified": 1709237383,
|
"lastModified": 1711703276,
|
||||||
"narHash": "sha256-cy6ArO4k5qTx+l5o+0mL9f5fa86tYUX3ozE1S+Txlds=",
|
"narHash": "sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "1536926ef5621b09bba54035ae2bb6d806d72ac8",
|
"rev": "d8fe5e6c92d0d190646fb9f1056741a229980089",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -98,11 +98,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1710781103,
|
"lastModified": 1711963903,
|
||||||
"narHash": "sha256-nehQK/XTFxfa6rYKtbi8M1w+IU1v5twYhiyA4dg1vpg=",
|
"narHash": "sha256-N3QDhoaX+paWXHbEXZapqd1r95mdshxToGowtjtYkGI=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "treefmt-nix",
|
"repo": "treefmt-nix",
|
||||||
"rev": "7ee5aaac63c30d3c97a8c56efe89f3b2aa9ae564",
|
"rev": "49dc4a92b02b8e68798abd99184f228243b6e3ac",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
# Development shell configuration
|
# Development shell configuration
|
||||||
devShell = {
|
devShell = {
|
||||||
hlsCheck.enable = false;
|
hlsCheck.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
# What should haskell-flake add to flake outputs?
|
# What should haskell-flake add to flake outputs?
|
||||||
|
|
|
||||||
16
fourmolu.yaml
Normal file
16
fourmolu.yaml
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Generated from web app, for more information, see: https://fourmolu.github.io/config/
|
||||||
|
indentation: 4
|
||||||
|
column-limit: none
|
||||||
|
function-arrows: leading
|
||||||
|
comma-style: trailing
|
||||||
|
import-export-style: diff-friendly
|
||||||
|
indent-wheres: false
|
||||||
|
record-brace-space: true
|
||||||
|
newlines-between-decls: 1
|
||||||
|
haddock-style: multi-line
|
||||||
|
haddock-style-module: single-line
|
||||||
|
let-style: auto
|
||||||
|
in-style: right-align
|
||||||
|
single-constraint-parens: always
|
||||||
|
unicode: never
|
||||||
|
respectful: false
|
||||||
19
src/Main.hs
19
src/Main.hs
|
|
@ -25,9 +25,7 @@ import System.Environment qualified as SE
|
||||||
data HuffmanTree a
|
data HuffmanTree a
|
||||||
= Leaf a
|
= Leaf a
|
||||||
| Node
|
| Node
|
||||||
{ left :: HuffmanTree a
|
{left :: HuffmanTree a, right :: HuffmanTree a}
|
||||||
, right :: HuffmanTree a
|
|
||||||
}
|
|
||||||
deriving (Eq, Ord, Show, Generic, C.Serialize)
|
deriving (Eq, Ord, Show, Generic, C.Serialize)
|
||||||
|
|
||||||
data TreeDir = L | R deriving (Eq, Ord, Show, Generic, C.Serialize)
|
data TreeDir = L | R deriving (Eq, Ord, Show, Generic, C.Serialize)
|
||||||
|
|
@ -43,7 +41,6 @@ decompress :: forall a. (Ord a, Integral a, B.FiniteBits a) => Maybe ([TreeDir],
|
||||||
decompress Nothing = Just []
|
decompress Nothing = Just []
|
||||||
decompress (Just (treeDirs, tree)) = decompress' treeDirs
|
decompress (Just (treeDirs, tree)) = decompress' treeDirs
|
||||||
where
|
where
|
||||||
|
|
||||||
decompress' :: [TreeDir] -> Maybe [a]
|
decompress' :: [TreeDir] -> Maybe [a]
|
||||||
decompress' [] = Just []
|
decompress' [] = Just []
|
||||||
decompress' xs = case nextLeaf xs tree of
|
decompress' xs = case nextLeaf xs tree of
|
||||||
|
|
@ -77,7 +74,7 @@ compress bs =
|
||||||
testCompression :: forall a. (Ord a, Eq a, Integral a, B.FiniteBits a) => D.Proxy a -> BS.ByteString -> Bool
|
testCompression :: forall a. (Ord a, Eq a, Integral a, B.FiniteBits a) => D.Proxy a -> BS.ByteString -> Bool
|
||||||
testCompression _ bs = ((Just . toBitsList $ bs) :: Maybe [a]) == (decompress . compress $ bs)
|
testCompression _ bs = ((Just . toBitsList $ bs) :: Maybe [a]) == (decompress . compress $ bs)
|
||||||
|
|
||||||
encodeCompressed :: C.Serialize a => Maybe ([TreeDir], HuffmanTree a) -> BS.ByteString
|
encodeCompressed :: (C.Serialize a) => Maybe ([TreeDir], HuffmanTree a) -> BS.ByteString
|
||||||
encodeCompressed = C.encode . fmap (Bi.first encodeTreeDirs)
|
encodeCompressed = C.encode . fmap (Bi.first encodeTreeDirs)
|
||||||
where
|
where
|
||||||
encodeTreeDirs = BV.cloneToByteString . V.fromList . map (BV.Bit . (== R))
|
encodeTreeDirs = BV.cloneToByteString . V.fromList . map (BV.Bit . (== R))
|
||||||
|
|
@ -122,12 +119,12 @@ finiteBitUncons bs =
|
||||||
rest :: BS.ByteString
|
rest :: BS.ByteString
|
||||||
(takenBytes, rest) = BS.splitAt numBytes bs
|
(takenBytes, rest) = BS.splitAt numBytes bs
|
||||||
|
|
||||||
compressionRatioFor ::
|
compressionRatioFor
|
||||||
forall a.
|
:: forall a
|
||||||
(Integral a, B.FiniteBits a, Ord a, C.Serialize a) =>
|
. (Integral a, B.FiniteBits a, Ord a, C.Serialize a)
|
||||||
D.Proxy a ->
|
=> D.Proxy a
|
||||||
BS.ByteString ->
|
-> BS.ByteString
|
||||||
Double
|
-> Double
|
||||||
compressionRatioFor proxy bs =
|
compressionRatioFor proxy bs =
|
||||||
(/ (fromIntegral . BS.length $ bs))
|
(/ (fromIntegral . BS.length $ bs))
|
||||||
. fromIntegral
|
. fromIntegral
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue