yesod-page-cursor-2.0.1.0
Safe HaskellNone
LanguageHaskell2010

Yesod.Page

Synopsis

Documentation

withPageLink Source #

Arguments

:: (MonadHandler m, ToJSON position, FromJSON position, RenderRoute (HandlerSite m)) 
=> Int

Default limit if not specified in the Cursor

Must be a positive natural number.

-> (a -> position)

How to get an item's position

For example, this would be entityKey for paginated Entity values.

-> (Cursor position -> m [a])

How to fetch one page of data at the given Cursor

-> m [a] 

withPage and adding pagination data to a Link response header

Links added by this function are relative. See withPageLinkAbsolute.

withPageLinkAbsolute Source #

Arguments

:: (MonadHandler m, ToJSON position, FromJSON position, Yesod (HandlerSite m), RenderRoute (HandlerSite m)) 
=> Int

Default limit if not specified in the Cursor

Must be a positive natural number.

-> (a -> position)

How to get an item's position

For example, this would be entityKey for paginated Entity values.

-> (Cursor position -> m [a])

How to fetch one page of data at the given Cursor

-> m [a] 

withPage and adding pagination data to a Link response header

If you've set an approot, links added by this function will be absolute using it. If not, this function will be equivalent to withPageLink.

withPage Source #

Arguments

:: (MonadHandler m, ToJSON position, FromJSON position, RenderRoute (HandlerSite m)) 
=> Int

Default limit if not specified in the Cursor

Must be a positive natural number.

-> (a -> position)

How to get an item's position

For example, this would be entityKey for paginated Entity values.

-> (Cursor position -> m [a])

How to fetch one page of data at the given Cursor

-> m (Page a) 

Paginate data and construct a Page object.

Links added by this function are relative. See withPageAbsolute.

withPageAbsolute Source #

Arguments

:: (MonadHandler m, ToJSON position, FromJSON position, Yesod (HandlerSite m), RenderRoute (HandlerSite m)) 
=> Int

Default limit if not specified in the Cursor

Must be a positive natural number.

-> (a -> position)

How to get an item's position

For example, this would be entityKey for paginated Entity values.

-> (Cursor position -> m [a])

How to fetch one page of data at the given Cursor

-> m (Page a) 

withPage, but using absolute links

If you've set an approot, links added by this function will be absolute using it. If not, this function will be equivalent to withPage.

data Page a Source #

Instances

Instances details
Functor Page Source # 
Instance details

Defined in Yesod.Page

Methods

fmap :: (a -> b) -> Page a -> Page b #

(<$) :: a -> Page b -> Page a #

ToJSON a => ToJSON (Page a) Source # 
Instance details

Defined in Yesod.Page

data Cursor position Source #

An encoding of the position in a page

A Cursor encodes all necessary information to determine the position in a specific page.

Constructors

Cursor 

Fields

data Position position Source #

Constructors

First 
Next position 
Previous position 
Last 

Instances

Instances details
ToJSON position => ToJSON (Position position) Source # 
Instance details

Defined in Yesod.Page

Methods

toJSON :: Position position -> Value #

toEncoding :: Position position -> Encoding #

toJSONList :: [Position position] -> Value #

toEncodingList :: [Position position] -> Encoding #

FromJSON position => FromJSON (Position position) Source # 
Instance details

Defined in Yesod.Page

Methods

parseJSON :: Value -> Parser (Position position) #

parseJSONList :: Value -> Parser [Position position] #