title: Class set method in Haskell using State-Monad
body: <p>I've recently had a look at Haskell's Monad - State. I've been able to create functions that operate with this Monad, but I'm trying to encapsulate the behavior into a class, basically I'm trying to replicate in Haskell something like this:</p>
  
  <pre><code>class A {
    public:
    int x;
    void setX(int newX) {
        x = newX;
    }
    void getX() {
        return x;
    }
  }
  </code></pre>
  
  <p>I would be very grateful if anyone can help with this. Thanks!</p>