Sapling Logo
Grammar API quickstart

Haskell Grammar Checker

Add spelling and grammar suggestions to a Haskell application with Sapling's edits API.

  • HTTPS POST
  • HTTP API
  • API key required
POST Haskell logo Haskell /api/v1/edits

Haskell grammar checker quickstart

Send text to the edits endpoint. Sapling returns suggested replacements with character offsets so your application can review or apply each correction.

No language-specific SDK is required. The example uses a standard or commonly used HTTP client to call Sapling's JSON API.
Haskell /api/v1/edits
import Data.Aeson
import Network.HTTP.Client

main = do
  putStrLn "Hello"
  putStrLn "World"
  s  :: String_type
  url  :: String_type
  manager <- newManager defaultManagerSettings
  s = "{\"key\":\"API_KEY\", \"text\":\"Lets get started!\", \"session_id\":\"Test Document UUID\"}"
  url = "https://api.sapling.ai/api/v1/edits"
  nakedRequest <- parseRequest url
  request = nakedRequest { method = "POST", requestBody = body }
  response <- httpLbs request manager
  let Just obj = decode (responseBody response)
  print (obj :: Object)
Example response application/json
{
  "edits": [
    {
      "start": 0,
      "end": 4,
      "replacement": "Let's",
      "sentence": "Lets get started!",
      "error_type": "R:OTHER"
    }
  ]
}

Each edit identifies the source range and replacement text. Preserve the original offsets when applying more than one edit.

About Haskell

Haskell is a popular programming language in industry and academia. It is purely functional, declarative, and statically typed.