This repository has been archived by the owner on Apr 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 175
/
CodingStyle
45 lines (30 loc) · 1.47 KB
/
CodingStyle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
* GHC support
GHC 7.4, 7.6 and 7.8 are supported at this moment. If GHC 7.10 is
released, the support for GHC 7.4 will be discontinued.
* Compiler warnings
All compiler warnings generated by the latest stable GHC with "-Wall"
MUST be eliminated.
* Deceleration style
Try to use "where" instead of "let".
* Error handling
As a general rule of thumb anything that can fail (as in the Monad
method) should get a surrounding catchError with a description of what
the function was trying to do. If a function is trying to do more than
one thing it should probably be split up into multiple seperate
functions anyways.
All uses of the major partial functions (i.e fromJust, fromLeft, head
etc.) should probably be replaced by pattern matching in the do block
(since pattern match failures are very easy to handle with
catchError).
We also have to be careful with anything that uses liftIO since that
might introduce unexpected exceptions. For example parseCabalFile
still uses IOError's for error reporting which would circumvent ErrorT
and make handling that error with MonadError impossible. Stuff like
that should probably be converted to GhcModT or return IO (Either
String SomeThing) instead. It should be pretty easy to write a
function to lift IO (Either e a) into a GhcModT a (where e could be
String, ´GhcModError` or something like that).
* #if
"#if __GLASGOW_HASKELL__" should be used in "Gap.hs" and "Monad.hs"
only. If it is used in another file, it should be moved into
"Gap.hs".