listsafe 0.1.0.0 → 0.1.0.1
raw patch · 3 files changed
+14/−8 lines, 3 filesdep ~exceptionsnew-uploader
Dependency ranges changed: exceptions
Files
- Data/List/Safe.hs +7/−5
- LICENSE.md +1/−1
- listsafe.cabal +6/−2
Data/List/Safe.hs view
@@ -118,8 +118,10 @@ -- |List index (subscript) operator, starting from 0. Indices larger than -- @length xs - 1@ throw an 'EmptyListException', negative indices throw -- an 'NegativeIndexException'. -(!!) :: (MonadThrow m, Integral n, Num n) => [a] -> n -> m a -(!!) [] _ = throwM EmptyListException -(!!) (x:xs) n | n == 0 = return x - | n < 0 = throwM NegativeIndexException - | otherwise = (!!) xs (n-1) +(!!) :: (MonadThrow m, Integral n) => [a] -> n -> m a +(!!) xs i = index xs (toInteger i) + where + index [] _ = throwM EmptyListException + index (x:xs) n | n == 0 = return x + | n < 0 = throwM NegativeIndexException + | otherwise = (!!) xs (n-1)
LICENSE.md view
@@ -187,7 +187,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [yyyy] [name of copyright owner] + Copyright 2014 Janos Tapolczai Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
listsafe.cabal view
@@ -1,5 +1,5 @@ name: listsafe -version: 0.1.0.0 +version: 0.1.0.1 synopsis: Safe wrappers for partial list functions, supporting MonadThrow. description: Data.List includes a handful of partial functions that throw uncatchable exceptions when given empty lists. This package @@ -15,8 +15,12 @@ build-type: Simple cabal-version: >=1.10 +source-repository head + type: git + location: git://github.com/ombocomp/listsafe.git + library exposed-modules: Data.List.Safe other-extensions: DeriveDataTypeable - build-depends: base >=4.7 && <5, exceptions >=0.4 && <0.7 + build-depends: base >=4.7 && <5, exceptions >=0.4 default-language: Haskell2010