google-search-0.2.0.0: EDSL for Google and GMail search expressions

Safe HaskellSafe
LanguageHaskell98

Language.Google.Search.Simple

Contents

Description

An orphan lives in this module,

instance (Functor f, IsString a) => IsString (Free f a)

so that we can write "simple queries" :: Simple.

Synopsis

Documentation

Units

data Duration Source

Constructors

Days 
Months 
Years 

Instances

data Size Source

Constructors

Bytes 
KBytes 
MBytes 

Instances

Search expression construction

data PrecBuilder Source

Builder with precedence, though ambiguous associativity. (But that's okay because Google doesn't mind which way you lean.)

Note that at Google OR binds tighter than conjunction, which is flipped in contrast to everywhere else. We take the analogous Haskell fixities when building search expressions:

  • 11: atomic tokens or parenthesised expressions
  • 10: complementation, search operators (cf. Haskell prefix application)
  • 3: disjunction (OR or |)
  • 2: conjunction (by juxtaposition)

Constructors

PrecBuilder Int Builder 

parentheses :: Int -> ((PrecBuilder -> Builder) -> Builder) -> PrecBuilder Source

Give me the precedence of the piece of syntax you're building, and I'll give you a function that parenthesise any sub-expressions when necessary.

class SearchBuilder e where Source

Render a search expression using Google search syntax.

Generalised Boolean operators

class DisjunctF f where Source

Methods

disjunctF :: e -> e -> f e Source

class Disjunct e where Source

Methods

(\/) :: e -> e -> e infixr 2 Source

Instances

class ConjunctF f where Source

Methods

conjunctF :: e -> e -> f e Source

class Conjunct e where Source

Methods

(/\) :: e -> e -> e infixr 3 Source

Instances

class ComplementF f where Source

Methods

complementF :: e -> f e Source

class Complement e where Source

Methods

notB :: e -> e Source

Instances

andB :: Conjunct e => [e] -> e Source

andB is to /\ what and is to &&.

orB :: Disjunct e => [e] -> e Source

orB is to \/ what or is to ||.

Primitive Terms

data Term t Source

Fuzzy terms are grouped with parentheses (if necessary), while Exact terms are always “double-quoted”. The IsString instance defaults to Fuzzy, so just writing "literal string" ∷ Term Text is acceptable.

Constructors

Fuzzy t 
Exact t 

Boolean expressions

data BooleanF e Source

The shape of Boolean expressions.

Constructors

NotB e 
e `AndB` e infixr 3 
e `OrB` e infixr 2 

type BooleanM = Free BooleanF Source

The free Boolean-shaped monad. No refunds.

type Simple = BooleanM (Term Text) Source

Simple Boolean combinations of Terms.