Skip to content
TOML parser/encoder written in haskell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


hatoml - TOML parser/encoder written in haskell


TOML (Tom's Obvious Minimal Language) by Tom Preston-Werner is a simple configuration file format inspired by JSON and YAML.


You can build hatoml using cabal:

$ cabal configure
$ cabal build

Using it in your haskell programs is pretty straightforward as well:

import qualified Data.ByteString.Char8 as BS
import           Data.HaTOML

parseFile :: FilePath -> IO (Either String TOML)
parseFile f = parse `fmap` BS.readFile f


As of now hatoml is compatible with TOML v0.2 4f23be43e42775493f142e7dd025b6227e037dd9 except from arrays of tables (which I hope to implement real soon).


This is what an example TOML file looks like:

# This is a TOML document. Boom.

title = "TOML Example"

name = "Tom Preston-Werner"
organization = "GitHub"
bio = "GitHub Cofounder & CEO\nLikes tater tots and beer."
dob = 1979-05-27T07:32:00Z # First class dates? Why not?

server = ""
ports = [ 8001, 8001, 8002 ]
connection_max = 5000
enabled = true


  # You can indent as you please. Tabs or spaces. TOML don't care.
  ip = ""
  dc = "eqdc10"

  ip = ""
  dc = "eqdc10"

data = [ ["gamma", "delta"], [1, 2] ]

# Line breaks are OK when inside arrays
hosts = [

hatoml parses the above TOML file into the following data structure:

 (TOML (fromList [
  ("clients", TGroup (TOML (fromList [
   ("data", TArray [
     TArray [
      TString "gamma",
      TString "delta"],
     TArray [
      TInteger 1,
      TInteger 2]]),
   ("hosts", TArray [
    TString "alpha", TString "omega"])]))),
  ("database", TGroup (TOML (fromList [
   ("connection_max", TInteger 5000),
   ("enabled", TBool True),
   ("ports", TArray [
    TInteger 8001,
    TInteger 8001,
    TInteger 8002]),
   ("server", TString "")]))),
  ("owner", TGroup (TOML (fromList [
   ("bio", TString "GitHub Cofounder & CEO\nLikes tater tots and beer."),
   ("dob", TDate 1979-05-27 07:32:00 UTC),
   ("name", TString "Tom Preston-Werner"),
   ("organization", TString "GitHub")]))),
  ("servers", TGroup (TOML (fromList [
   ("alpha", TGroup (TOML (fromList [
    ("dc", TString "eqdc10"),
    ("ip", TString "")]))),
   ("beta", TGroup (TOML (fromList [
    ("dc", TString "eqdc10"),
    ("ip", TString "")])))]))),
  ("title", TString "TOML Example")]))


  • Support for arrays of tables
  • Better error messages
  • Further look into encoding logic
  • Implement some convenience functions (i.e. lookup, set ...)
  • More unit tests
You can’t perform that action at this time.