Matching with functions in OCaml? -


Is it possible to use patterns directly or with some adventures to match on specific functions, which Need it?

Just like to explain things, I feel like a type of

  type BBoolOp = (bool-> gt; bool- & gt; bool) * * The word  

and looks like bool-gt; Bool- & gt; Bool functions are some very simple such as (& amp; amp;) (||) ..

depending on what function It is possible to do different things:

  with match Bop (||) - & gt; Do something. (& Amp; amp;) - & gt; Do something else  

This should not be possible because the function can not be compared but what I'm trying to use to use it :)

In advance thanks

The function is to compare, as you mention, unsupported In some cases it can work, but IOM is not good.

So I'll use just one algebraic data type to solve this problem. You can achieve some flexibility in the pattern-matching-over-function concept using polymorphic forms (not necessarily pattern matching code to know about all possible operators). Type either

  BBoolOper = and | Or type BBoolOp = BBoolOper * word * word  

or

  type BBoolOp = [& lt; `And | `Or] * word * (* opened / closed as required *)  

Comments