Improve documentation

This commit is contained in:
Gregor Kleen 2017-10-25 23:15:56 +02:00
parent 6916f0746d
commit f094b80c0a
5 changed files with 14 additions and 2 deletions

View File

@ -1,3 +1,6 @@
# 0.0.0.1
- Improved documentation
# 0.0.0.0
First published version

View File

@ -1,5 +1,5 @@
name: filepath-crypto
version: 0.0.0.0
version: 0.0.0.1
synopsis: Reversable and secure encoding of object ids as filepaths
license: BSD3
license-file: LICENSE

View File

@ -6,5 +6,8 @@ module Data.Binary.SerializationLength.Class
import GHC.TypeLits
-- | The class of types for which the result of serialization with @Data.Binary@
-- is known statically to be of a certain length
class KnownNat (SerializationLength a) => HasFixedSerializationLength a where
-- | The 'SerializationLength' is given in bytes at type level
type SerializationLength a :: Nat

View File

@ -10,6 +10,12 @@ import Data.Binary.SerializationLength.Class
hasFixedSerializationLength :: Name -> Integer -> DecsQ
-- | Shorthand for defining instances of 'HasFixedSerializationLength', morally:
--
-- > hasFixedSerializationLength typeName byteN = [d|
-- > instance HasFixedSerializiationLength $(typeName) where
-- > type SerializationLength $(typeName) = $(byteN)
-- > |]
hasFixedSerializationLength (return . ConT -> t) (return . LitT . NumTyLit -> i) =
[d|
instance HasFixedSerializationLength $(t) where

View File

@ -60,11 +60,11 @@ import Data.Proxy
import GHC.TypeLits
-- | @serializedLength@ is given in bytes.
type CryptoFileName (namespace :: Symbol) = CryptoID namespace (CI FilePath)
paddedLength :: Integral a => a -> a
-- | Round up to nearest multiple of 'cipherBlockSize'
paddedLength l = bs * ceiling (l % bs)
where bs = fromIntegral cipherBlockSize