Skip to content

Instantly share code, notes, and snippets.

@techtangents
Created July 11, 2013 04:30
Show Gist options
  • Save techtangents/5972547 to your computer and use it in GitHub Desktop.
Save techtangents/5972547 to your computer and use it in GitHub Desktop.

There seems to be a lot of confusion around Effects and IO. I wanted to collect a set of questions and answers, and explanations of common misconceptions.

  1. What is an Effect?
  2. What is a Side Effect?
  3. What is a pure function?
  4. What is equational reasoning?
  5. What is an IO?
  6. Is the purpose IO value used to model an effectful computation, such that it can be composed with other computations?
  7. Is Haskell's unsafePerformIO an impure function?
  8. Related: Is it true that forall a, IO a is
  9. Do the terms 'pure' and 'impure' only apply to functions?
  10. The following Haskell functions have different semantics. In the former, getLine is evaluated once and its resulting value duplicated. In the latter, getLine is evaluated twice. These two values have the same type. Can you offer any relevant insights about the difference in these two programs, in relation to evaluation and equational reasoning? Is there anything significant about the fact that getLine is effectful that does not apply to a pure function? Is the difference in semantics inherent in the difference between the Monad implementations? a = liftM (\ a -> [a, a]) getLine b = sequence [getLine, getLine]
  11. What other types are used to model effects?
  12. Are all effectful computations Monads? Are some only Functors or Applicatives?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment