I am not sure if this is possible. The first hurdle is getting an applicative and monad instance. The naive applicative implementation gives this error:
src/EIO.hs:54:15-54: error:
• Couldn't match type ‘e’ with ‘e <> e’
Expected: EIO e b
Actual: EIO (e <> e) b
‘e’ is a rigid type variable bound by
the instance declaration
at src/EIO.hs:53:10-28
• In the expression: af >>= \ f -> ax >>= \ x -> return (f x)
In an equation for ‘<*>’:
af <*> ax = af >>= \ f -> ax >>= \ x -> return (f x)
In the instance declaration for ‘Applicative (EIO e)’
• Relevant bindings include
ax :: EIO e a (bound at src/EIO.hs:54:10)
af :: EIO e (a -> b) (bound at src/EIO.hs:54:3)
(<*>) :: EIO e (a -> b) -> EIO e a -> EIO e b
(bound at src/EIO.hs:54:6)
|
54 | af <*> ax = af >>= \ f -> ax >>= \ x -> return (f x)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I am not sure if this is possible. The first hurdle is getting an applicative and monad instance. The naive applicative implementation gives this error: