Where should I put a `condp` like function?
Idan Arye
GenericNPC at gmail.com
Thu Apr 18 07:18:55 PDT 2013
On Thursday, 18 April 2013 at 13:04:19 UTC, Graham Fawcett wrote:
> On Sunday, 14 April 2013 at 23:52:37 UTC, Idan Arye wrote:
>>
>> Now, I've got it working(the example actually compiles and
>> prints "less then 5"), and I want to make a pull request to
>> put it in Phobos(because it's a useful function) but I don't
>> really know where to put it. None of the existing modules
>> seems fit, and I don't want to open a new module(std.monad?)
>> for a single function.
>
> Nit-picky observation: there's nothing monadic about your
> predSwitch function, it wouldn't belong in a 'std.monad' module.
>
> Best,
> Graham
A monad is "a structure that represents computations"(quote from
Wikipedia). While the Turing machine branch(=the main branch) of
computability theory quickly fell into the Turing tarpit and had
to moved to pseudo-code, the Lambda calculus was expended using
the traditional mathematical method of defining symbols that
replace other symbols.
That's why when in the Turing machine branch you could just write
`if ... then ... else ...` and it's okay because it's
pseudo-code, in Lambda calculus you actually have an IFTHENELSE
defined as a lambda expression. And so on with loops, exception
handling, and even type definitions and input/output.
I find that `predSwitch` - a function that represents the
`switch` idiom - perfectly fits into the definition of monads.
More information about the Digitalmars-d
mailing list