[Haskell-cafe] Defining new operators

Shachaf Ben-Kiki shachaf at gmail.com
Fri Aug 10 17:31:59 EDT 2007


> Hi all,
>
> Given the follwing function:
>
> > owner :: Step -> Scenario
> > owner (Step id scenario action state response) = scenario
>
> Is it possible to define the owner function in such way that I can write x.owner (returning the scenario related with the Step x)?

Some people use (|>), which looks like an arrow:

> (|>) :: a -> (a -> b) -> b
> x |> f = f x

Then you can use "step |> owner".

Also consider using:

> data Step = Step { ..., scenario :: Scenario, ... }

    Shachaf


More information about the Haskell-Cafe mailing list