Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Functions that brick event handlers can use to search forward or backward for certain kinds of items in brick list.
For example, in the above demo program, you can search forward or backward for a list element that is not a separator.
Synopsis
- type IncludeCurrent = Bool
- searchListForward :: Searchable t => IncludeCurrent -> (e -> Bool) -> GenericList n t e -> Maybe Int
- searchListBackward :: Searchable t => IncludeCurrent -> (e -> Bool) -> GenericList n t e -> Maybe Int
- listSearchDown :: Searchable t => (e -> Bool) -> GenericList n t e -> GenericList n t e
- listSearchUp :: Searchable t => (e -> Bool) -> GenericList n t e -> GenericList n t e
- listSearchFromBeginning :: (Searchable t, Foldable t, Splittable t) => (e -> Bool) -> GenericList n t e -> GenericList n t e
- listSearchFromEnd :: (Searchable t, Foldable t, Splittable t) => (e -> Bool) -> GenericList n t e -> GenericList n t e
- listSearchPageUp :: (Searchable t, Foldable t, Splittable t, Ord n) => (e -> Bool) -> EventM n (GenericList n t e) ()
- listSearchPageDown :: (Searchable t, Foldable t, Splittable t, Ord n) => (e -> Bool) -> EventM n (GenericList n t e) ()
- class Searchable (t :: * -> *) where
Types
type IncludeCurrent = Bool Source #
Should the search include the current location?
Low-level functions
These functions are used in list manipulation.
:: Searchable t | |
=> IncludeCurrent | |
-> (e -> Bool) | The test |
-> GenericList n t e | |
-> Maybe Int | The first element index that passes the test |
Search forward for the first element index that passes the test
:: Searchable t | |
=> IncludeCurrent | |
-> (e -> Bool) | The test |
-> GenericList n t e | |
-> Maybe Int | The first element index that passes the test |
Search backward for the first element index that passes the test
List manipulation
:: Searchable t | |
=> (e -> Bool) | The test |
-> GenericList n t e | |
-> GenericList n t e |
Search forward for the first element that passes the test.
The current element is not included in the search.
If forward search fails, no change is made.
:: Searchable t | |
=> (e -> Bool) | The test |
-> GenericList n t e | |
-> GenericList n t e |
Search backward for the first element that passes the test.
The current element is not included in the search.
If backward search fails, no change is made.
listSearchFromBeginning Source #
:: (Searchable t, Foldable t, Splittable t) | |
=> (e -> Bool) | The test |
-> GenericList n t e | |
-> GenericList n t e |
From the first element, search forward for the first element that passes the test.
The first element is included in the search.
If forward search fails, no change is made.
:: (Searchable t, Foldable t, Splittable t) | |
=> (e -> Bool) | The test |
-> GenericList n t e | |
-> GenericList n t e |
From the last element, search backward for the first element that passes the test.
The last element is included in the search.
If backward search fails, no change is made.
:: (Searchable t, Foldable t, Splittable t, Ord n) | |
=> (e -> Bool) | The test |
-> EventM n (GenericList n t e) () |
Move up one page, and search backward for the first element that passes the test.
The element chosen by moving up one page is included in the search.
If backward search fails, search forward for the first element that passes the test.
If forward search fails too, cancel movements made by this function.
:: (Searchable t, Foldable t, Splittable t, Ord n) | |
=> (e -> Bool) | The test |
-> EventM n (GenericList n t e) () |
Move down one page, and search forward for the first element that passes the test.
The element chosen by moving down one page is included in the search.
If forward search fails, search backward for the first element that passes the test.
If backward search fails too, cancel movements made by this function.
Classes
class Searchable (t :: * -> *) where Source #
Functions for searching elements.
viewHead :: t a -> Maybe (a, t a) Source #
Get the head and the rest
viewLast :: t a -> Maybe (t a, a) Source #
Get the last element and the rest
take :: Int -> t a -> t a Source #
Take a number of elements from the beginning
drop :: Int -> t a -> t a Source #
Drop a number of elements from the beginning
Instances
Searchable Seq Source # | O(1) for viewHead and viewLast. O(log(min(i,n-i))) for take and drop. |
Searchable Vector Source # | O(1) for all operations |