module Data.AdaptiveTuple.AdaptiveTuple (
AdaptiveTuple (..)
,AdaptiveTupleException (..)
,oObExcp
,insExcp
)
where
import Data.TypeLevel.Num
import Data.Data
import Control.Exception
import Control.Applicative
class (Nat s, Applicative (c s)) => AdaptiveTuple c s where
getIndex :: c s el -> Int -> el
setIndex :: Int -> el -> c s el -> c s el
mapIndex :: (el -> el) -> Int -> c s el -> c s el
toATuple :: [el] -> c s el
fromATuple :: c s el -> [el]
tupLength :: c s el -> Int
tupLength _ = toInt (undefined :: s)
data AdaptiveTupleException =
ATupleIndexOutOfBounds String
| ATupleInsufficientInput
deriving (Show, Typeable)
instance Exception AdaptiveTupleException
oObExcp :: String -> a
oObExcp = throw . ATupleIndexOutOfBounds
insExcp :: a
insExcp = throw ATupleInsufficientInput