How can I access a list by index in Haskell, analog to this C code?
int a[] = { 34, 45, 56 }; return a[1];
I know it's an old post ... but it may be useful for someone ... in a "functional" way ...
import Data.List safeIndex :: [a] -> Int -> Maybe a safeIndex xs i | (i> -1) && (length xs > i) = Just (xs!!i) | otherwise = Nothing