Skip to main content

Haskell Query API

To use the Haskell API:

import Glean
import Glean.Angle

Or import qualified if you prefer:

import qualified Glean
import qualified Glean.Angle as Angle

Using Haxl​

Glean comes with a Haxl API for performing queries. The advantages of using the Haxl API are:

  • Queries can be performed concurrently without using explicit threads or Control.Concurrent.Async. Applicative combinators such as sequence or mapM are performed concurrently in the Haxl monad, and GHC's ApplicativeDo extension can be used to enable implicit concurrency within a sequence of statements in a do expression.

  • When traversing the results of a query, instead of using the expand query modifier to recursively fetch the entire result, Haxl provides a family of get operations to iteratively fetch nested facts in the result. When performed concurrently in the Haxl monad, multiple calls to get are batched into a single request to Glean. This makes it efficient to do shallow queries and then selectively traverse and expand the results as needed.

To use the API, import Glean.Haxl. The implementation of the API is in glean/haxl/Haxl/DataSource/Glean.hs.