Skip to content

Noodle is a generic serializing and parsing library that provides json, yaml and toml implementations.

License

Notifications You must be signed in to change notification settings

MartinFillon/noodle

Repository files navigation

noodle

Example Usage :

{-# LANGUAGE DeriveGenerics #-}
{-# LANGUAGE MultiParamTypeClasses #-}

import GHC.Generics (Generic)
import Noodle.Json (prettyPrintJson, Json)
import Noodle.Yaml (prettyPrintYaml, Yaml)
import Noodle.Serialize (Serialize (..))
import Noodle.Deserialize (Serialize (..))
import Noodle.Deserializer (Deserializer)

data Test = Test
    { foo :: Double,
      bar :: Bool,
      taz :: [Int]
    }
    deriving (Show, Generic)

data Person = Person {
    age :: Age,
    bar' :: Test,
    name :: String
} deriving (Show, Generic)

data Age = Age Double deriving (Show, Generic)

data T2 = T2 Int | T3 Bool deriving (Show, Generic)

instance Serializer f => Serialize T2 f
instance Serializer f => Serialize Age f
instance Serializer f => Serialize Test f
instance Serializer f => Serialize Person f

instance Deserializer f => Deserialize T2 f
instance Deserializer f => Deserialize Age f
instance Deserializer f => Deserialize Test f
instance Deserializer f => Deserialize Person f

testJson :: Serialize a Json => a -> IO ()
testJson = putStrLn . prettyPrintJson . serialize

testYaml :: Serialize a Yaml => a -> IO ()
testYaml = putStrLn . prettyPrintYaml . serialize

About

Noodle is a generic serializing and parsing library that provides json, yaml and toml implementations.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published