oessessnex

joined 2 years ago
[–] oessessnex@programming.dev 11 points 2 years ago* (last edited 2 years ago)

Nope. Monads enable you to redefine how statements work.

Let's say you have a program and use an Error[T] data type which can either be Ok {Value: T} or Error:

var a = new Ok {Value = 1};
var b = foo();
return new Ok {Value = (a + b)};

Each statement has the following form:

var a = expr;
rest

You first evaluate the "expr" part and bind/store the result in variable a, and evaluate the "rest" of the program.

You could represent the same thing using an anonymous function you evaluate right away:

(a => rest)(expr);

In a normal statement you just pass the result of "expr" to the function directly. The monad allows you to redefine that part.

You instead write:

bind((a => rest), expr);

Here "bind" redefines how the result of expr is passed to the anonymous function.

If you implement bind as:

B bind(Func[A, B] f, A result_expr) {
   return f(result_expr);
}

Then you get normal statements.

If you implement bind as:

Error[B] bind(Func[A, Error[B]] f, Error[A] result_expr) {
   switch (result_expr) {
       case Ok { Value: var a}:
           return f(a);
       case Error:
           return Error;
   }
}

You get statements with error handling.

So in an above example if the result of foo() is Error, the result of the statement is Error and the rest of the program is not evaluated. Otherwise, if the result of foo() is Ok {Value = 3}, you pass 3 to the rest of the program and you get a final result Ok {Value = 4}.

So the whole idea is that you hide the if Error part by redefining how the statements are interpreted.

[–] oessessnex@programming.dev 1 points 2 years ago

You can probably replace it with ImageMagick.

[–] oessessnex@programming.dev 25 points 2 years ago* (last edited 2 years ago)

Some people consider working on programming languages fun, so they create new ones.

[–] oessessnex@programming.dev 1 points 2 years ago

If you want to make games, start with a text based adventure game, something like Zork. Learn as you go, you will need console IO and data structures to represent game state, puzzles, levels. Then make a 2D game. After that you will probably be proficient enough to make anything you want.

[–] oessessnex@programming.dev 3 points 2 years ago

Turn JavaScript into Bash with these easy steps...

[–] oessessnex@programming.dev 8 points 2 years ago

First focus on working on projects instead of improving your skills. The concepts you learn are usually a solution to some problem. Things are easier if you first encounter the problem yourself and then learn the solution, than if you do it in reverse. It is ok to do things poorly when you are starting out.

[–] oessessnex@programming.dev 0 points 2 years ago* (last edited 2 years ago) (1 children)

IIRC Voat also added the option to block communities, which prevented the hateful ones from showing up on the front page.

That obviously didn't help...

view more: ‹ prev next ›