Haskell EDN
An EDN parsing and encoding library.
Based on spec and hints published on GitHub.
Hackage: https://hackage.haskell.org/package/hedn
Stackage: https://www.stackage.org/package/hedn
Tutorial: https://dpwiz.gitlab.io/hedn
Examples
AST
(#haskell/edn example/kitchensink ; tagged symbol
nil ; ugh..
\space ; character
"dynamic \"typing\"" ; string
{:numbers ; keyword
[42 ; integer
42.0 ; floating
] ; Vector
:bools
#{true, false} ; Set (with optional commas)
} ; Map
) ; List
import qualified Data.EDN as EDN
import qualified Data.Text.IO as Text
main = do
edn <- Text.readFile "example.edn"
either error print $ EDN.parseText "example.edn" edn
NoTag
(List
[ Tagged "haskell" "edn" (Symbol "example" "kitchensink")
, NoTag Nil
, NoTag (Character ' ')
, NoTag (String "dynamic \"typing\"")
, NoTag
(Map
(fromList
[ ( NoTag (Keyword "bools")
, NoTag
(Set (fromList [ NoTag (Boolean False) , NoTag (Boolean True) ]))
)
, ( NoTag (Keyword "numbers")
, NoTag (Vec [ NoTag (Integer 42) , NoTag (Floating 42.0) ])
)
]))
])