indentation foo, and a new coding style page. no code changes
This commit is contained in:
parent
dd63cbb7bc
commit
6eca362c5d
11 changed files with 395 additions and 301 deletions
|
@ -136,8 +136,12 @@ withEncryptedContent = pass withEncryptedHandle
|
||||||
withDecryptedContent :: Cipher -> IO L.ByteString -> (L.ByteString -> IO a) -> IO a
|
withDecryptedContent :: Cipher -> IO L.ByteString -> (L.ByteString -> IO a) -> IO a
|
||||||
withDecryptedContent = pass withDecryptedHandle
|
withDecryptedContent = pass withDecryptedHandle
|
||||||
|
|
||||||
pass :: (Cipher -> IO L.ByteString -> (Handle -> IO a) -> IO a)
|
pass
|
||||||
-> Cipher -> IO L.ByteString -> (L.ByteString -> IO a) -> IO a
|
:: (Cipher -> IO L.ByteString -> (Handle -> IO a) -> IO a)
|
||||||
|
-> Cipher
|
||||||
|
-> IO L.ByteString
|
||||||
|
-> (L.ByteString -> IO a)
|
||||||
|
-> IO a
|
||||||
pass to n s a = to n s $ a <=< L.hGetContents
|
pass to n s a = to n s $ a <=< L.hGetContents
|
||||||
|
|
||||||
hmacWithCipher :: Cipher -> String -> String
|
hmacWithCipher :: Cipher -> String -> String
|
||||||
|
|
|
@ -249,7 +249,8 @@ fileKey file = file2key $
|
||||||
{- for quickcheck -}
|
{- for quickcheck -}
|
||||||
prop_idempotent_fileKey :: String -> Bool
|
prop_idempotent_fileKey :: String -> Bool
|
||||||
prop_idempotent_fileKey s = Just k == fileKey (keyFile k)
|
prop_idempotent_fileKey s = Just k == fileKey (keyFile k)
|
||||||
where k = stubKey { keyName = s, keyBackendName = "test" }
|
where
|
||||||
|
k = stubKey { keyName = s, keyBackendName = "test" }
|
||||||
|
|
||||||
{- Two different directory hashes may be used. The mixed case hash
|
{- Two different directory hashes may be used. The mixed case hash
|
||||||
- came first, and is fine, except for the problem of case-strict
|
- came first, and is fine, except for the problem of case-strict
|
||||||
|
|
|
@ -107,7 +107,6 @@ gen r u _ = new <$> remoteCost r defcst
|
||||||
, remotetype = remote
|
, remotetype = remote
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
{- Checks relatively inexpensively if a repository is available for use. -}
|
{- Checks relatively inexpensively if a repository is available for use. -}
|
||||||
repoAvail :: Git.Repo -> Annex Bool
|
repoAvail :: Git.Repo -> Annex Bool
|
||||||
repoAvail r
|
repoAvail r
|
||||||
|
@ -402,12 +401,12 @@ rsyncParamsRemote r sending key file afile = do
|
||||||
| end ps == [dashdash] = ps ++ [source, dest]
|
| end ps == [dashdash] = ps ++ [source, dest]
|
||||||
| otherwise = ps ++ [dashdash, source, dest]
|
| otherwise = ps ++ [dashdash, source, dest]
|
||||||
dashdash = Param "--"
|
dashdash = Param "--"
|
||||||
-- The rsync shell parameter controls where rsync
|
{- The rsync shell parameter controls where rsync
|
||||||
-- goes, so the source/dest parameter can be a dummy value,
|
- goes, so the source/dest parameter can be a dummy value,
|
||||||
-- that just enables remote rsync mode.
|
- that just enables remote rsync mode.
|
||||||
-- For maximum compatability with some patched rsyncs,
|
- For maximum compatability with some patched rsyncs,
|
||||||
-- the dummy value needs to still contain a hostname,
|
- the dummy value needs to still contain a hostname,
|
||||||
-- even though this hostname will never be used.
|
- even though this hostname will never be used. -}
|
||||||
dummy = Param "dummy:"
|
dummy = Param "dummy:"
|
||||||
|
|
||||||
rsyncParams :: Git.Repo -> Annex [CommandParam]
|
rsyncParams :: Git.Repo -> Annex [CommandParam]
|
||||||
|
@ -434,7 +433,6 @@ commitOnCleanup r a = go `after` a
|
||||||
-- have a new enough git-annex shell to
|
-- have a new enough git-annex shell to
|
||||||
-- support committing.
|
-- support committing.
|
||||||
liftIO $ catchMaybeIO $ do
|
liftIO $ catchMaybeIO $ do
|
||||||
print "!!!!!!!!!!!!!"
|
|
||||||
withQuietOutput createProcessSuccess $
|
withQuietOutput createProcessSuccess $
|
||||||
proc shellcmd $
|
proc shellcmd $
|
||||||
toCommand shellparams
|
toCommand shellparams
|
||||||
|
|
86
doc/coding_style.mdwn
Normal file
86
doc/coding_style.mdwn
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
If you do nothing else, avoid use of partial functions from the Prelude!
|
||||||
|
`import Utility.PartialPrelude` helps avoid this by defining conflicting
|
||||||
|
functions for all the common ones. Also avoid `!!`, it's partial too.
|
||||||
|
|
||||||
|
Use tabs for indentation. The one exception to this rule are
|
||||||
|
the Hamlet format files in `templates/*`. Hamlet, infuriatingly, refuses
|
||||||
|
to allow tabs to be used for indentation.
|
||||||
|
|
||||||
|
Code should make sense with any tab stop setting, but 8 space tabs are
|
||||||
|
the default. With 8 space tabs, code should not exceed 80 characters
|
||||||
|
per line. (With larger tabs, it may of course.)
|
||||||
|
|
||||||
|
Use spaces for layout. For example, here spaces (indicated with `.`
|
||||||
|
are used after the initial tab to make the third test line up with
|
||||||
|
the others.
|
||||||
|
|
||||||
|
when (foo_test || bar_test ||
|
||||||
|
......some_other_long_test)
|
||||||
|
print "hi"
|
||||||
|
|
||||||
|
As a special Haskell-specific rule, "where" clauses are indented with two
|
||||||
|
spaces, rather than a tab. This makes them stand out from the main body
|
||||||
|
of the function, and avoids excessive indentation of the where cause content.
|
||||||
|
The definitions within the where clause should be put on separate lines,
|
||||||
|
each indented with a tab.
|
||||||
|
|
||||||
|
foo = do
|
||||||
|
foo
|
||||||
|
bar
|
||||||
|
foo
|
||||||
|
where
|
||||||
|
foo = ...
|
||||||
|
bar = ...
|
||||||
|
|
||||||
|
Where clauses for instance definitions and modules tend to appear at the end
|
||||||
|
of a line, rather than on a separate line.
|
||||||
|
|
||||||
|
instance MonadBaseControl IO Annex where
|
||||||
|
|
||||||
|
When a function's type signature needs to be wrapped to another line,
|
||||||
|
it's typical to switch to displaying one parameter per line.
|
||||||
|
|
||||||
|
foo :: Bar -> Baz -> (Bar -> Baz) -> IO Baz
|
||||||
|
|
||||||
|
foo'
|
||||||
|
:: Bar
|
||||||
|
-> Baz
|
||||||
|
-> (Bar -> Baz)
|
||||||
|
-> IO Baz
|
||||||
|
|
||||||
|
Note that the "::" then starts its own line. It is not put on the same
|
||||||
|
line as the function name because then it would not be guaranteed to line
|
||||||
|
up with the "->" at all tab width settings. Similarly, guards are put
|
||||||
|
on their own lines:
|
||||||
|
|
||||||
|
splat i
|
||||||
|
| odd i = error "splat!"
|
||||||
|
| otherwise = i
|
||||||
|
|
||||||
|
Multiline lists and record syntax are written with leading commas,
|
||||||
|
that line up with the open and close punctuation.
|
||||||
|
|
||||||
|
list =
|
||||||
|
[ item1
|
||||||
|
, item2
|
||||||
|
, item3
|
||||||
|
]
|
||||||
|
|
||||||
|
foo = DataStructure
|
||||||
|
{ name = "bar"
|
||||||
|
, address = "baz"
|
||||||
|
}
|
||||||
|
|
||||||
|
Module imports are separated into two blocks, one for third-party modules,
|
||||||
|
and one for modules that are part of git-annex. (Additional blocks can be used
|
||||||
|
if it makes sense.)
|
||||||
|
|
||||||
|
Using tabs for indentation makes use of `let .. in` particularly tricky.
|
||||||
|
There's no really good way to bind multiple names in a let clause with
|
||||||
|
tab indentation. Instead, a where clause is typically used. To bind a single
|
||||||
|
name in a let clause, this is sometimes used:
|
||||||
|
|
||||||
|
foo = let x = 42
|
||||||
|
in x + (x-1) + x
|
||||||
|
|
||||||
|
(Of course, monadic let binding are no problem.)
|
|
@ -33,3 +33,8 @@ The git repository has some branches:
|
||||||
* `setup` contains configuration for this website
|
* `setup` contains configuration for this website
|
||||||
* `pristine-tar` contains [pristine-tar](http://kitenet.net/~joey/code/pristine-tar)
|
* `pristine-tar` contains [pristine-tar](http://kitenet.net/~joey/code/pristine-tar)
|
||||||
data to create tarballs of any past git-annex release.
|
data to create tarballs of any past git-annex release.
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
Developing git-annex? Patches are very welcome.
|
||||||
|
You should read [[coding_style]].
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue