Given the functions:
let doTrue = fun(x) -> true
let doFalse = fun(x) -> false
I want to reuse the function signature so that i can get
let myFunDefinition = ??? // <-- this is the function signature that i am trying to reuse
let doTrue = myFunDefinition -> true // <-- now i don't have to type fun(x) any more
let doFalse = myFunDefinition -> false
Is it possible to define for reuse a function signature?
Even after the edits, your question doesn’t really make sense to me. First of all, the signature of
doTrueanddoFalseis'a -> boolas you have written them, but I don’t think that this is really relevant to your question because I don’t see what it would mean to “reuse” the signature. Instead, it seems like you want some form of text macro that will allow you to typemyFunDefinitionand have that replaced by the textfun (x). Aside from the fact that your replacement text is longer than the original text, here are a few thoughts:let doTrue x = ...instead oflet doTrue = fun x -> ...If you actually want
doTrueanddoFalseto be the application of some other function totrueandfalse, then that is easy:In this case, perhaps this is what you’re looking for:
(?) This just ignores the second argument (which becomes the first argument of
doTrueanddoFalsebecause they partially applymyFunDefinitionto the first arguments oftrueorfalse, respectively).