Effective application programming can be seen as accepting regular inefficient computing and adding effects to them. They are implemented as Applicative instances. Thus, although Int is a regular value, A Int is Int with some effect A , and A is an Applicative instance.
Consider this expression:
x + y :: Int
This expression is ineffective; it deals only with regular, equal values, so to speak. But we can also have an effective supplement.
One effect is failure; calculation may fail or succeed. If this fails, then the calculation stops. This is just a Maybe type.
Just (+1) <*> Nothing :: Maybe Int
Besides the usual values, you just add numbers together. But now we have an addition that may fail. Therefore, we must add the numbers together, provided that the calculation did not work. In this expression, we see that the calculation will fail because the second operand is Nothing .
If your calculations may fail for more than one reason, you may want to receive error messages that report a failure. Then you can use the error effect, which can be represented as something like an Either String ( String is a type of error message). The implementation of this Applicative behaves similarly to Maybe Applicative .
Another example of an effect is parsing. Analysis can be implemented by using designers and ensuring their effectiveness. Suppose you want to implement a simple arithmetic language with addition and multiplication. This could be your abstract syntax tree (AST):
data Exp = Num Int | Var String data AST = Add Exp Exp | Multiply Exp Exp
You create an AST simply using these constructors. But the problem is that you also need to actually parse the text, so what about the parsing act? How about tracking how much text you spent? What if parsing fails because the text does not match your grammar? Well, in libraries like Parsec , this is a parsing effect. You are using some Parse data type (this is an Applicative instance) and take constructors to the efficient world of Parse AST . Now you can build an AST by actually parsing the text, because parsing is an effect added to the AST construct.
Note that the Parse type was more complex than the Maybe and Either String instances; the parser has the effect of tracking the state, for example, how much input text is consumed and the parsing failed, which would give an error message. Applicative effects can be composed together.