List.hs (552B)
1 module Lude.List ( 2 List, 3 index, 4 ( #? ), 5 ) where 6 7 import Lude.Haskell 8 import Lude.Haskell.List (List) 9 import Lude.Maybe 10 import Lude.Natural 11 12 -- TODO: pindex, (!!) :: (Partial) => ... 13 14 -- TODO: Somehow generalize indices beyond Natural (e.g., Nat64 should also work?) 15 16 -------------------------------------------------------------------------------- 17 18 index, ( #? ) :: forall (a :: Type). List a -> Natural -> Maybe a 19 index [] _ = Nothing 20 index (h : _) NaturalZero = Just h 21 index (_ : t) (NaturalSucc n) = index t n 22 ( #? ) = index 23 infixl 9 #?