@@ -3,6 +3,7 @@ module Main (main) where
3import Asyncly
3import Asyncly
4import Control.Applicative ((<|>))
4import Control.Applicative ((<|>))
5import Control.Concurrent (myThreadId, threadDelay)
5import Control.Concurrent (myThreadId, threadDelay)
6+import Data.Monoid ((<>))
6import Control.Monad.IO.Class (liftIO)
7import Control.Monad.IO.Class (liftIO)
7import Data.List (nub, sort)
8import Data.List (nub, sort)
8import Test.Hspec
9import Test.Hspec
@@ -23,6 +24,8 @@ main = hspec $ do
23 toList (return 1 >> return 2) `shouldReturn` ([2] :: [Int])
24 toList (return 1 >> return 2) `shouldReturn` ([2] :: [Int])
24 it "Bind and toList" $
25 it "Bind and toList" $
25 toList (do x <- return 1; y <- return 2; return (x + y)) `shouldReturn` ([3] :: [Int])
26 toList (do x <- return 1; y <- return 2; return (x + y)) `shouldReturn` ([3] :: [Int])
27+ it "Monoid composition" $
28+ toList (return 0 <> return 1) `shouldReturn` ([0, 1] :: [Int])
26 it "Alternative composition" $
29 it "Alternative composition" $
27 ((toList $ (return 0 <|> return 1)) >>= return . sort) `shouldReturn` ([0, 1] :: [Int])
30 ((toList $ (return 0 <|> return 1)) >>= return . sort) `shouldReturn` ([0, 1] :: [Int])