Haskell synonym definition -
could explain me following synonim means , how read it:
type tcm = errort string (statet myenv io) what able understand till now:
we introduce new name type , call tcm , has parameter a
we have value constructor errort (what makes errort?) takes 3 arguments: string, (statet myenv io) , a
(statet myenv io) - here have value constructor statet , args myenv , io. type makes?
am right? explain me how works? responses.
edit: maybe me this. have sth following function in program evaluate integer:
ms_exp :: exp -> tcm () ms_exp (eint integer) = return integer and have such error:
couldn't match expected type `()' actual type `integer' any hints?
well,
errorttype hadatype parameter, if wished, specialize it, is, make typetype tcmint = errort string (statet myenv io) inthowever, can leave type parameter, did in example.
no,
errortnot value constructor, type constructor. makes element oferrort? well, depends onerrortis. suppose control.monad.error, , said is constructedrunerrortfunction.again,
statetnot value constructor, type constructor (creatednewtypekeyword acoording this). can seenewtype state s a,statetype constructors expects 2 type names construct type, code passesmyenv,io, yieldingstatet myenv iotype.
to update: function expects inject element of () tcm monad doing return () while return integer. need either return () or change type of ms_exp exp -> tcm integer.
Comments
Post a Comment