Skip to content

Instantly share code, notes, and snippets.

@sordina
Created March 15, 2010 08:40
Show Gist options
  • Save sordina/332630 to your computer and use it in GitHub Desktop.
Save sordina/332630 to your computer and use it in GitHub Desktop.
{-# LANGUAGE MultiParamTypeClasses, FlexibleContexts #-}
{- -- Has the error:
Matrix.hs:33:49:
Kind error: `m' is applied to too many type arguments
In the type `m (Maybe a)'
In the type `Integer -> m (Maybe a)'
In the type `Integer -> Integer -> m (Maybe a)'
--}
module Matrix (
Matrix,
fromRows,
toList,
toListWithPos,
toRows,
rows,
columns,
at,
neighbours,
neighbourMap
) where
import Data.Maybe (catMaybes)
class Matrix m
where
-- required
fromRows :: [[a]] -> m
rows :: m -> Integer
columns :: m -> Integer
at :: m -> Integer -> Integer -> a
-- defaults
toList :: m -> [a]
toListWithPos :: m -> [(Integer, Integer, a)]
toRows :: m -> [[a]]
row :: m -> Integer -> [a]
column :: m -> Integer -> [a]
vicinityRows :: m -> Integer -> Integer -> [[Maybe a]]
vicinityMatrix :: m -> Integer -> Integer -> m (Maybe a)
neighbours :: m -> Integer -> Integer -> [a]
neighbourMap :: (a -> [a] -> a) -> m -> m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment