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?

  1. well, errort type had a type parameter, if wished, specialize it, is, make type

    type tcmint = errort string (statet myenv io) int 

    however, can leave type parameter, did in example.

  2. no, errort not value constructor, type constructor. makes element of errort? well, depends on errort is. suppose control.monad.error, , said is constructed runerrort function.

  3. again, statet not value constructor, type constructor (created newtype keyword acoording this). can see newtype state s a, state type constructors expects 2 type names construct type, code passes myenv , io, yielding statet myenv io type.

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

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -