cpython-3.3.0: Bindings for libpython

Safe HaskellNone

CPython.Protocols.Sequence

Synopsis

Documentation

castToSequence :: Object a => a -> IO (Maybe SomeSequence)Source

Attempt to convert an object to a generic Sequence. If the object does not implement the sequence protocol, returns Nothing.

length :: Sequence self => self -> IO IntegerSource

repeat :: Sequence a => a -> Integer -> IO aSource

setItem :: (Sequence self, Object v) => self -> Integer -> v -> IO ()Source

deleteItem :: Sequence self => self -> Integer -> IO ()Source

setSlice :: (Sequence self, Object v) => self -> Integer -> Integer -> v -> IO ()Source

deleteSlice :: Sequence self => self -> Integer -> Integer -> IO ()Source

count :: (Sequence self, Object v) => self -> v -> IO IntegerSource

contains :: (Sequence self, Object v) => self -> v -> IO BoolSource

index :: (Sequence self, Object v) => self -> v -> IO IntegerSource

Return the first index i for which self[i] == v. This is equivalent to the Python expression self.index(v).

toList :: Sequence seq => seq -> IO ListSource

Return a list object with the same contents as the arbitrary sequence seq. The returned list is guaranteed to be new.

toTuple :: Sequence seq => seq -> IO TupleSource

Return a tuple object with the same contents as the arbitrary sequence seq. If seq is already a tuple, it is re-used rather than copied.

fast :: Sequence seq => seq -> Text -> IO SomeSequenceSource

Returns the sequence seq as a tuple, unless it is already a tuple or list, in which case seq is returned. If an error occurs, throws TypeError with the given text as the exception text.