Monday, 15 February 2010

Reader Monad in Purescript -


I was playing with Reader Moned in Pyruscript and I had to face a strange behavior. I do not know if this is a lack of understanding of this monkey or if I am missing something else.

This is my code:

  type level = type doc = reader level string renderline :: string - & gt; Level - & gt; String Reader Line s 0 = s Radar Line s = "\ t" ++ (Render Line s (L-1)) Line :: String - & gt; Doctor Line s = What level & lt; - Ask Return (Level of Renderline)  

This is OK and will compile. Despite this, before this I tried to simplify my function line like this:

  line :: string -> Doctor line s = do level & lt; - "Hello reader monad"  

Ask for a return and the fact that despite the renderline level and "Hello Reader monade", the same type will not be compiled. This will throw me this error: "No examples were found for control." Monad Reader Class. Monad Reader u14555 (Control Monaad.Reader Trans.Reader Prime Number Control.Monad Identity Identification) "< / P>

I'm sure I'm missing something, but I do not know.

Another error would be a readable version:

Monad Reader Did not find any examples? (Reader number)

I think the problem here is due to the lack of functional reliability in PureScript due to the MonadReader class in Haskell defined as MonadReader RM has been done. M - & gt; R therefore the rule of r is m , but we can not do it in the Purposics.

I suspect why this works because instead of the latter, the case of pre level type level in the call , which means r should also be level .

As you are not doing anything with level In the latter case, the type variable has been left - integrated, and the place where the error occurs because There is no real example for MonadReader when r is unknown.


No comments:

Post a Comment