On 8/9/07, rodrigo.bonifacio <[EMAIL PROTECTED]> wrote:
>
> Hi all.
>
> I want to overload the operator "^" for working instead of the following
> "+++" operator:
>
> (+++) :: String -> [[String]] -> [[String]]
> x +++ y = [ x:e | e<-y ]
>
> How can I overload the "^" operator?


import Prelude hiding ( (^) )  -- this is the key

(^) :: String -> [[String]] -> [[String]]
x ^ y = [ x:e | e<-y ]

By the way, there's nothing special about Strings here: if you made the type
of ^

(^) :: a -> [[a]] -> [[a]]

it would work on lists of any type, including String.

-Brent
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to