servant-activeresource: Servant endpoints compatible with Rails's ActiveResource

[ bsd3, library, servant, web ] [ Propose Tags ] [ Report a vulnerability ]

ActiveResource is a Rails library for representing resources from a RESTful API as Ruby objects, with a similar interface to the Rails ActiveRecord ORM.

This library provides types for describing such APIs, and functions to help implement Servant-style servers that provide them.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.2.0.0
Change log CHANGELOG.md
Dependencies aeson (>=2.1.1.0 && <2.3), base (>=4.14 && <4.22), bytestring (>=0.10.12 && <0.13), containers (>=0.6 && <0.8), servant (>=0.19 && <0.21), servant-server (>=0.19 && <0.21), text (>=1.2 && <1.3 || >=2.0 && <=2.2) [details]
Tested with ghc ==8.10.7 || ==9.0.2 || ==9.2.4 || ==9.4.5 || ==9.6.6 || ==9.8.2 || ==9.10.1 || ==9.12.1
License BSD-3-Clause
Copyright Copyright (C) 2024-2025 Bellroy Pty Ltd
Author Bellroy Tech Team <haskell@bellroy.com>
Maintainer Bellroy Tech Team <haskell@bellroy.com>
Category Servant, Web
Home page https://github.com/bellroy/servant-activeresource
Bug tracker https://github.com/bellroy/servant-activeresource/issues
Source repo head: git clone https://github.com/bellroy/servant-activeresource.git
Uploaded by jack at 2025-06-24T05:33:42Z
Distributions NixOS:0.1.0.0
Downloads 56 total (1 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2025-06-24 [all 1 reports]

Readme for servant-activeresource-0.2.0.0

[back to package description]

servant-activeresource

ActiveResource is a Rails library for representing resources from a RESTful API as Ruby objects, with a similar interface to the Rails ActiveRecord ORM.

This library provides types for describing such APIs, and functions to help implement Servant-style servers that provide them.

import qualified Servant.ActiveResource as AR

newtype MyResourceId = MyResourceId Int
-- Type for new values or updates to existing values. Usually
-- missing an `id` field.
data MyResource = MyResource {...}
-- Like MyResource, but returned from the database.
data MyStoredResource = MyStoredResource {...}

-- These type family instances associate your resource's ID type
-- with the data types accepted and returned by your operations and
-- by the servant-server API.
type instance ResourceData MyResourceId = MyResource
type instance StoredResourceData MyResourceId = MyStoredResource

-- Record of routes, which can passed directly to
-- 'Servant.Server.Generic.genericServe', or spliced into another
-- record of routes via 'Servant.API.NamedRoutes'.
--
-- The exact monad used will depend on your program. Here, we just
-- assume 'Handler' from package servant-server.
routes :: AR.ResourceRoutes MyResourceId AsServer
routes = AR.makeResourceRoutes ResourceOperations
  { listResources = ...
  , createResource = ...
  , readResource = ...
  , upsertResource = ...
  , deleteResource = ...
  }