genRotations = do
  let defs = [ "{-# INLINE maskbits #-}"
             , "maskbits v m b = (v .&. (complement m) .|. b)"
             , ""
             , "{-# INLINE tb #-}"
             , "tb v i j m =  m .|. (rotate  (v .&. (bit i)) (j-i))"
             ]

  putStrLn $ unlines defs

  forM_ [0..3] $ \q ->
    forM_ [True,False] $ \cw -> do
      genRotation q cw
      putStrLn ""
genRotations = do
  let defs = [ "{-# INLINE maskbits #-}"
             , "maskbits v m b = (v .&. (complement m) .|. b)"
             , ""
             , "{-# INLINE tb #-}"
             , "tb v i j m =  m .|. (rotate  (v .&. (bit i)) (j-i))"
             ]

  putStrLn $ unlines defs

  forM_ [0..3] $ \q ->
    forM_ [True,False] $ \cw -> do
      genRotation q cw
      putStrLn ""
genRotations = do
  let defs = [ "{-# INLINE maskbits #-}"
             , "maskbits v m b = (v .&. (complement m) .|. b)"
             , ""
             , "{-# INLINE tb #-}"
             , "tb v i j m =  m .|. (rotate  (v .&. (bit i)) (j-i))"
             ]

  putStrLn $ unlines defs

  forM_ [0..3] $ \q ->
    forM_ [True,False] $ \cw -> do
      genRotation q cw
      putStrLn ""