[Haskell-cafe] How to write a pure String to String function in Haskell FFI to C++
Ting Lei
tinlyx at gmail.com
Mon Jun 3 01:22:50 CEST 2013
Hi,
I want to implement a function in C++ via Haskell FFI, which should have
the (final) type of String -> String.
Say, is it possible to re-implement the following function in C++ with the
exact same signature?
import Data.Char
toUppers:: String -> String
toUppers s = map toUpper senter code here
In particular, I wanted to avoid having an IO in the return type because
introducing the impurity
(by that I mean the IO monad) for this simple task is logically
unnecessary. All examples involing
a C string I have seen so far involve returning an IO something or Ptr
which cannot be converted back to a pure String.
The reason I want to do this is that I have the impression that marshaling
is not easy with FFI. Maybe
if I can fix the simplest case above (other than primitive types such as
int), then I can do whatever data
parsing I want on the C++ side, which should be easy, practically.
The cost of parsing is negligible compared to the computation that I want
to do between
the marshalling to/from strings.
Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130602/9f110d81/attachment.htm>
More information about the Haskell-Cafe
mailing list