From 60d744e32f64dbe8badadbd60d2b5e3d092ec8a2 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 29 Dec 2012 13:38:13 +0000 Subject: [PATCH] haskell: Implement 'head' and 'tail' by hiding the Prelude functions. --- generator/haskell.ml | 41 +++++++++++++++++------------------------ src/guestfs.pod | 6 ------ 2 files changed, 17 insertions(+), 30 deletions(-) diff --git a/generator/haskell.ml b/generator/haskell.ml index 21b251d1e..795f36c3d 100644 --- a/generator/haskell.ml +++ b/generator/haskell.ml @@ -34,27 +34,20 @@ let rec generate_haskell_hs () = (* See guestfs(3)/Haskell for limitations of the current Haskell * bindings. Please help out! XXX *) - let can_generate name style = - match name with - (* GHC error: "Ambiguous occurrence `head'" etc. because these - * clash with Prelude functions with the same name. - *) - | "head" | "tail" -> false - | _ -> - match style with - | _, _, (_::_) -> false (* no optional args yet *) - | RErr, _, [] - | RInt _, _, [] - | RInt64 _, _, [] - | RBool _, _, [] - | RConstString _, _, [] - | RString _, _, [] - | RStringList _, _, [] - | RHashtable _, _, [] -> true - | RStruct _, _, [] - | RStructList _, _, [] - | RBufferOut _, _, [] - | RConstOptString _, _, [] -> false + let can_generate = function + | _, _, (_::_) -> false (* no optional args yet *) + | RErr, _, [] + | RInt _, _, [] + | RInt64 _, _, [] + | RBool _, _, [] + | RConstString _, _, [] + | RString _, _, [] + | RStringList _, _, [] + | RHashtable _, _, [] -> true + | RStruct _, _, [] + | RStructList _, _, [] + | RBufferOut _, _, [] + | RConstOptString _, _, [] -> false in pr "\ @@ -66,7 +59,7 @@ module Guestfs ( (* List out the names of the actions we want to export. *) List.iter ( fun { name = name; style = style } -> - if can_generate name style then pr ",\n %s" name + if can_generate style then pr ",\n %s" name ) all_functions; pr " @@ -75,7 +68,7 @@ module Guestfs ( -- Unfortunately some symbols duplicate ones already present -- in Prelude. We don't know which, so we hard-code a list -- here. -import Prelude hiding (truncate) +import Prelude hiding (head, tail, truncate) import Foreign import Foreign.C @@ -138,7 +131,7 @@ assocListOfHashtable (a:b:rest) = (a,b) : assocListOfHashtable rest List.iter ( fun { name = name; style = (ret, args, optargs as style); c_function = c_function } -> - if can_generate name style then ( + if can_generate style then ( pr "foreign import ccall unsafe \"guestfs.h %s\" c_%s\n" c_function name; pr " :: "; diff --git a/src/guestfs.pod b/src/guestfs.pod index 11622a278..68226c491 100644 --- a/src/guestfs.pod +++ b/src/guestfs.pod @@ -949,12 +949,6 @@ A tiny number of obscure functions that return constant strings =back -=item * - -The functions L and L are not -bound, because these names conflict with C and -C. - =back =item B