winnerOf :: State -> Maybe Player
winnerOf s = maybe Nothing id $
        find isJust $ map winner rows ++ map winner cols ++ map winner diags
    where
        winner [a, b, c] = 
            if all isRight [a, b, c] && a == b && b == c
            then Just (fromRight a) else Nothing
        rows  = map (\i -> toList $ slice (3*i) 3 (board s)) [0..2]
        cols  = map (\i -> map ((!) $ board s) [i, i+3, i+6]) [0..2]
        diags = map (map ((!) (board s))) [[0, 4, 8], [2, 4, 6]]

-- temporary tests to see if shit works
winnerOf :: State -> Maybe Player
winnerOf s = maybe Nothing id $
        find isJust $ map winner rows ++ map winner cols ++ map winner diags
    where
        winner [a, b, c] = 
            if all isRight [a, b, c] && a == b && b == c
            then Just (fromRight a) else Nothing
        rows  = map (\i -> toList $ slice (3*i) 3 (board s)) [0..2]
        cols  = map (\i -> map ((!) $ board s) [i, i+3, i+6]) [0..2]
        diags = map (map ((!) (board s))) [[0, 4, 8], [2, 4, 6]]

-- temporary tests to see if shit works
winnerOf s = maybe Nothing id $
        find isJust $ map winner rows ++ map winner cols ++ map winner diags
    where
        winner [a, b, c] = 
            if all isRight [a, b, c] && a == b && b == c
            then Just (fromRight a) else Nothing
        rows  = map (\i -> toList $ slice (3*i) 3 (board s)) [0..2]
        cols  = map (\i -> map ((!) $ board s) [i, i+3, i+6]) [0..2]
        diags = map (map ((!) (board s))) [[0, 4, 8], [2, 4, 6]]

-- temporary tests to see if shit works