Advertisement
Guest User

Untitled

a guest
Jan 28th, 2015
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. {-# LANGUAGE FlexibleInstances #-}
  2. {-# LANGUAGE IncoherentInstances #-}
  3. -- | Main entry point to the application.
  4. module Main where
  5. import Data.Monoid
  6. import Control.Monad
  7.  
  8. type Knight = (Int,Int)
  9.  
  10. move::Knight->[Knight]
  11. move (x,y) = do
  12. (x',y') <- [(x+1,y+2),(x+2,y+1),(x+1,y-2),(x+2,y-1),(x-1,y+2),(x-2,y+1),(x-1,y-2),(x-2,y-1)]
  13. guard $ (x' `elem` [1..8]) && (y' `elem` [1..8])
  14. return (x',y')
  15.  
  16. instance (Monad m) => Monoid (a-> m a) where
  17. mempty = return
  18. mappend = (>=>)
  19.  
  20. -- | The main entry point.
  21. main :: IO ()
  22. main = do
  23. print $ (mconcat [move | _ <- [1..1]]) (1,1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement