Skip to content

Instantly share code, notes, and snippets.

@tarquin-the-brave
Created May 12, 2020 13:36
Show Gist options
  • Save tarquin-the-brave/d4aff01d6bae08569ba4b547e8f980ae to your computer and use it in GitHub Desktop.
Save tarquin-the-brave/d4aff01d6bae08569ba4b547e8f980ae to your computer and use it in GitHub Desktop.
(!!!) :: Integral a => MonadFail m => [a] -> Int -> m a
infixl 9 !!!
xs !!! i
| i < 0 = fail $ "index " ++ show i ++ " less that zero"
| i >= length xs = return 0
| otherwise = return $ xs !! i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment