SHARE
TWEET

why-not-haskell

a guest Jan 14th, 2015 320 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Point data constructor
  2. data Point = Point Int Int
  3.  
  4. -- assuming import Data.Map in the beginning of the file
  5. makeWordMap ss = fromList $ [(w, s) | s <- ss, w <- words s]
  6.  
  7. -- A plotter class which we can make for any kind of a plotter
  8. class Plotter where
  9.   plot :: Point -> IO ()
  10.  
  11. plotSquares p n = sequence $ map (plot p) [Point x x+1 | x <- [0..n]]
  12.  
  13.  
  14. -- getting songs, do syntax
  15. getSongLength a b s = do album <- getAlbum a b
  16.                          song <- getSong b s
  17.                          return (length song)
  18.  
  19. -- alternatively a bit shorter and more intuitive
  20. getSongLength a b s =
  21.         fmap length $ getArtist a >>= getAlbum b >>= getSong s
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top