yesod-goodies-0.0.4.1: A collection of various small helpers useful in any yesod application.

Portabilityunportable
Stabilityunstable
Maintainerpbrisbin@gmail.com

Yesod.Goodies.Search

Contents

Description

 

Synopsis

Documentation

data SearchResult a Source

A ranked search result

Constructors

SearchResult 

Fields

searchRank :: Double
 
searchResult :: a
 

class Search a whereSource

Any item can be searched by providing a match function.

Methods

preference :: SearchResult a -> SearchResult a -> OrderingSource

If two results have the same rank, optionally lend preference to one. The greater value will appear first.

match :: Text -> a -> Maybe (SearchResult a)Source

Given a search term and some a, provide Just a ranked result or Nothing.

search :: Search a => Text -> [a] -> [SearchResult a]Source

Excute a search on a list of as and rank the results

search_ :: Search a => Text -> [a] -> [a]Source

Identical but discards the actual rank values.

weightedSearch :: Search a => (a -> Double) -> Text -> [a] -> [SearchResult a]Source

Add (or remove) weight from items that have certian properties.

weightedSearch_ :: Search a => (a -> Double) -> Text -> [a] -> [a]Source

search helpers

class TextSearch a whereSource

Being a member of this class means defining the way to represent your type as pure text so it can be searched by keyword, etc.

Methods

toText :: a -> TextSource

keywordMatch :: TextSearch a => Text -> a -> Maybe (SearchResult a)Source

Search term is interpreted as keywords. Results are ranked by the number of words that appear in the source text, a rank of 0 returns Nothing.