diff options
author | Nickolai Zeldovich <nickolai@csail.mit.edu> | 2016-02-08 16:08:10 -0500 |
---|---|---|
committer | Pierre Letouzey <pierre.letouzey@inria.fr> | 2016-05-04 10:39:08 +0200 |
commit | 78e616d56dc0646d0c67ab57e11671a6c08d0cc7 (patch) | |
tree | cdd87c9c4a94572f7cf9d62f13cd9b24defc1c1d | |
parent | dd7cf3a8086fa8a08a421314caec8543ba62226b (diff) |
Fix Haskell extraction for terms over 45 characters long
The Haskell extraction code would allow line-wrapping of the Haskell
type definition, which would lead to unparseable Haskell code when the
linebreak occured just before the type name. In particular, with a term
name of 46 characters or more, the following Coq code:
Definition xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx := tt.
Extraction Language Haskell.
Extraction xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
would produce:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ::
Unit
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx =
Tt
which failed to compile with GHC (according to Haskell's indentation
rules, the "Unit" line must be indented to be treated as a continuation
of the previous line).
This patch always forces the type onto a separate line, and ensures that
it is always indented by 2 spaces (just like the body of each definition).
-rw-r--r-- | plugins/extraction/haskell.ml | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/plugins/extraction/haskell.ml b/plugins/extraction/haskell.ml index 22519e347..764223621 100644 --- a/plugins/extraction/haskell.ml +++ b/plugins/extraction/haskell.ml @@ -346,7 +346,7 @@ let pp_decl = function in if void then mt () else - names.(i) ++ str " :: " ++ pp_type false [] typs.(i) ++ fnl () ++ + hov 2 (names.(i) ++ str " :: " ++ pp_type false [] typs.(i)) ++ fnl () ++ (if is_custom r then (names.(i) ++ str " = " ++ str (find_custom r)) else @@ -357,7 +357,7 @@ let pp_decl = function if is_inline_custom r then mt () else let e = pp_global Term r in - e ++ str " :: " ++ pp_type false [] t ++ fnl () ++ + hov 2 (e ++ str " :: " ++ pp_type false [] t) ++ fnl () ++ if is_custom r then hov 0 (e ++ str " = " ++ str (find_custom r) ++ fnl2 ()) else |