scfg: SCFG parser for Haskell

[ data, library, mit ] [ Propose Tags ] [ Report a vulnerability ]

A simple parser for SCFG (simple configuration format) files


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 1.0.0
Change log CHANGELOG.md
Dependencies base (>=4.19.0.0 && <4.21), megaparsec (>=9.7.0 && <9.8), text (>=2.1.0 && <2.2) [details]
Tested with ghc ==9.8.2 || ==9.10.3
License MIT
Author Marius Lysakerrud
Maintainer mail@marius.pm
Uploaded by MariusLy at 2026-03-29T16:30:59Z
Category Data
Home page https://git.sr.ht/~mariusl/haskell-scfg
Bug tracker https://lists.sr.ht/~mariusl/public-inbox
Source repo head: git clone https://git.sr.ht/~mariusl/haskell-scfg
Downloads 0 total (0 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2026-03-29 [all 1 reports]

Readme for scfg-1.0.0

[back to package description]

haskell-scfg

builds.sr.ht status

Haskell library for scfg.

Usage

{-# LANGUAGE OverloadedStrings #-}

import Data.Scfg (
    Directive (directiveChildren, directiveName, directiveParams),
    ParseError (errorMessage),
    parse,
 )
import Data.Text (Text)
import qualified Data.Text as T
import qualified Data.Text.IO as TIO

config :: Text
config =
    "train \"Shinkansen\" {\n\
    \  model \"E5\" {\n\
    \    max-speed 320km/h\n\
    \    weight 453.5t\n\
    \    lines-served \"Tōhoku\" \"Hokkaido\"\n\
    \  }\n\
    \  model \"E7\" {\n\
    \    max-speed 275km/h\n\
    \    weight 540t\n\
    \    lines-served \"Hokuriku\" \"Jōetsu\"\n\
    \  }\n\
    \}\n"

main :: IO ()
main = case parse config of
    Left err -> TIO.putStrLn $ "parse error: " <> errorMessage err
    Right cfg -> do
        let models = concatMap directiveChildren cfg
        mapM_ (\m -> TIO.putStrLn $ T.unwords (directiveName m : directiveParams m)) models

Contributing

Feel free to send patches to my public-inbox. Please note what change the patch will have on the version in accordance with the Haskell Package Versioning Policy (PVP).

License

MIT