On Dec 28, 2007 5:58 AM, Cristian Baboi <[EMAIL PROTECTED]> wrote:
> Here is how I want print to be in Haskell
>
> print :: (a->b) -> (a->b)
>
> with print = id, but the following "side effect":
>
> - I want to call the print function today, and get the value tomorrow.

You might be interested in the standard module Debug.Trace, which
defines a function:

   trace :: String -> b -> b

Which allows you to print something avoiding the IO monad as you seem
to want.  Then to get
your print function, all you would need is a Show instance for a -> b:

   print f = trace (show f) f

Then the Show instance:

   instance Show (a -> b) where
       show f = "<function>"

And there you have it.  It's not very useful, since it just prints
<function> for every function, but there you go.  I suspect you want
to print some serialization of the function such that it can be read
in again and executed later.  You're not gonna get that any time soon.

But I also suspect that there is another legitimate solution to your
problem.  Unless the problem has to do with transferring *arbitrary*
functions (that is, your program knows nothing at all about what is
transferred) between processes (not to be confused with threads, which
Haskell is very good at).

Luke
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to