Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rebind Haskell's proc-notation to user defined Arrows?

Tags:

haskell

ghc

To rebind Haskell's proc-notation, paragraph 7.3.11 "Rebindable syntax and the implicit Prelude import" of the GHC User's Guide states that the Arrow notation uses the arr, first, ... functions that are in scope. It also states that the types "must match the Prelude types very closely".

Anyone who wants to use this, is encouraged to ask. So, how close do these types have to match the Prelude types?

like image 380
frosch03 Avatar asked Nov 05 '22 17:11

frosch03


1 Answers

I'm not aware of any full documentation on rebinding the proc notation--I think this is in the category of things they tossed in there because it made sense to have it, but there aren't any clear motivating examples for using it yet.

I did a quick empirical test, enabling the relevant extensions, giving the rebound functions bogus types, and then looking at the type errors. What I saw was something roughly like this:

arr   :: (a -> b) -> t a b
(>>>) :: t a b -> t b c -> t a c
first :: t a b -> t (a, c) (b, c)

I assume the remaining functions are similar. Roughly, these are exactly the same types as the standard functions, minus only the Arrow constraint in the context.

like image 137
C. A. McCann Avatar answered Nov 09 '22 12:11

C. A. McCann