Hi,
I have noticed that most monads <M, return, then> are constructed by
abstraction on the feature they manage. For instance, the state monad
is of the form:
M a = s -> (a, s)
$s$ represents the state. Then we know that any term of type $M a$
is a function taking the feature as the first argument. More
generally, any monad constructed by abstraction on the feature they
manage gets this characteristic.
My question is: is there any monad that cannot be expressed in this way?
There exists some monads that are usually not expressed as an
abstraction but can be. For instance, the list monad,
M a = [a]
and the exception monad:
M a = Ok a | Error String
For the exception monad, we could use instead
M a = String -> (a, String)
where the string represents an error. If there is an error, the string
is non-empty and the value $a$ is not considered.
For the list monad, we could use
M a = [a] -> [a]
where the argument represents the rest of the list. I think that the
return and then functions could be defined by:
return x = \r -> (x:r)
m `then` k = \r ->
let (x:y) = m r
in k x y
I am not sure it works well though.
Does anyone know monads that could not been express as an
abstraction?
Regards,
Nicola
Francois-Nicola Demers
[EMAIL PROTECTED]
[EMAIL PROTECTED]