How do I write the function 'twice' in Haskell?

Posted by kunjaan on Stack Overflow See other posts from Stack Overflow or by kunjaan
Published on 2010-03-20T18:46:44Z Indexed on 2010/03/20 18:51 UTC
Read the original article Hit count: 181

Filed under:
|

I want to write 'twice' function that takes a function and an argument and applies the function twice. However the function that it receives should work on union types.

eg.

    f a -> b 
    f b -> c

Output

   twice f a
 c
   f a
   b
   f b 
   c
   f c
   error

© Stack Overflow or respective owner

Related posts about haskell

Related posts about types