Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> performs some side effects (I/O for instance),

What you're describing is the IO monad to first approximation, most monads don't perform side-effects at all ( List, Cont, Maybe, ... ) and the bind operations only performs some pure overloaded operation specific to the monad instance. For example the list monad performs the concatMap function which is pure.

    instance Monad [] where
      m >>= f        = concat (map f m)
      return x       = [x]


Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: