Skip to content

Instantly share code, notes, and snippets.

@liamoc
Created July 27, 2012 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liamoc/3187282 to your computer and use it in GitHub Desktop.
Save liamoc/3187282 to your computer and use it in GitHub Desktop.
Yaml example
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.Yaml
import System.Environment
import Control.Applicative
data Whatever = Foo { courses :: [String], required :: Int } deriving Show
instance FromJSON Whatever where
parseJSON (Object v) = Foo <$> (v .: "courses") <*> (v .: "required")
parseJSON _ = fail "Fucked!"
printWhatever :: [Whatever] -> IO ()
printWhatever = mapM_ print
main = fmap head getArgs >>= decodeFile >>= \(Just x) -> printWhatever x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment