haskell-scfg

[MIRROR] Haskell library for scfg

git clone git://git.marius.pm/haskell-scfg.git

commits

2026-03-29 bump version to 1.0.0 marius
2026-03-29 add hlint and fix warnings marius
2026-03-29 update dependency bounds marius
2026-03-28 add metadata to cabal file marius
2026-03-28 ensure readme badge is available outside srht marius

Clone the repository to access all 20 commits.

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