loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.5075434739251534","path":"main.hs","file":{"path":"main.hs","content":{"asEncoding":{"base64":"YWRkT25lIDo6IChNb25hZCBtLCBOdW0gYSkgPT4gYSAtPiBtIGEKYWRkT25lIGEgPSByZXR1cm4gKGEgKyAxKQoKbWFpbiA9IGRvCiAgcHJpbnQgJCBbIF0gICAgPj49IGFkZE9uZQogIHByaW50ICQgWzFdICAgID4+PSBhZGRPbmUKICBwcmludCAkIFsxLCAyXSA+Pj0gYWRkT25lCgogIHByaW50ICQgWyBdICAgID4+PSBhZGRPbmUgPj49IGFkZE9uZQogIHByaW50ICQgWzFdICAgID4+PSBhZGRPbmUgPj49IGFkZE9uZQogIHByaW50ICQgWzEsIDJdID4+PSBhZGRPbmUgPj49IGFkZE9uZQoKICAtLSBNYXliZQogIHByaW50ICQgTm90aGluZyA+Pj0gYWRkT25lCiAgcHJpbnQgJCBKdXN0IDEgID4+PSBhZGRPbmUKCiAgcHJpbnQgJCBOb3RoaW5nID4+PSBhZGRPbmUgPj49IGFkZE9uZQogIHByaW50ICQgSnVzdCAxICA+Pj0gYWRkT25lID4+PSBhZGRPbmUKCiAgLS0gRWl0aGVyCiAgcHJpbnQgJCAoTGVmdCAgMSA+Pj0gYWRkT25lIDo6IEVpdGhlciBJbnQgSW50KQogIHByaW50ICQgKFJpZ2h0IDEgPj49IGFkZE9uZSA6OiBFaXRoZXIgSW50IEludCkKCiAgcHJpbnQgJCAoUmlnaHQgMSA+Pj0gYWRkT25lID4+PSBhZGRPbmUgOjogRWl0aGVyIEludCBJbnQpCiAgcHJpbnQgJCAoTGVmdCAgMSA+Pj0gYWRkT25lID4+PSBhZGRPbmUgOjogRWl0aGVyIEludCBJbnQp"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
addOne :: (Monad m, Num a) => a -> m a
addOne a = return (a + 1)

main = do
  print $ [ ]    >>= addOne
  print $ [1]    >>= addOne
  print $ [1, 2] >>= addOne

  print $ [ ]    >>= addOne >>= addOne
  print $ [1]    >>= addOne >>= addOne
  print $ [1, 2] >>= addOne >>= addOne

  -- Maybe
  print $ Nothing >>= addOne
  print $ Just 1  >>= addOne

  print $ Nothing >>= addOne >>= addOne
  print $ Just 1  >>= addOne >>= addOne

  -- Either
  print $ (Left  1 >>= addOne :: Either Int Int)
  print $ (Right 1 >>= addOne :: Either Int Int)

  print $ (Right 1 >>= addOne >>= addOne :: Either Int Int)
  print $ (Left  1 >>= addOne >>= addOne :: Either Int Int)
GHCi, version 8.6.5