News for hackers. Stuff that matters.
Re:Why Haskell? by itishappy on Thursday September 12, 2024 @07:38PM (#41526798)
Got `maybeOut` wrong, can't edit, but it should be:

   maybeOut :: (a -> b) -> (a -> Maybe b)
   maybeOut = (.) Just
Also the parenthesis around the last two output types are added for emphasis, but can be safely removed.
Re:Why Haskell? by itishappy on Thursday September 12, 2024 @08:36PM (#41527080)
Last reply. Probably. Here's `maybe` in TypeScript:

    const maybe = <T,>(f: (_: T) => T, d:T) => (x: T|null) => f(x || d);

    console.log(maybe((x) => 2 * x, 3)(null)); // returns: 6