Skip to content

Commit

Permalink
fancier laziness test.
Browse files Browse the repository at this point in the history
  • Loading branch information
droundy committed Oct 24, 2009
1 parent 1bc1426 commit 5820fc9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 4 additions & 1 deletion YAML.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module YAML ( Node(..), YAML(..),
-- buildTree, unEscape, tokenize, tokenizeBytes,
getScalar, getMapping, getSequence,
getMappingValues, getMappingList,
getMappingValues, getMappingList, makeTree, makeTokens,
showYaml, readYaml, parseYaml, parseYamlList ) where

import YAML.Reference ( Code(..), tokenize ) -- , tokenizeBytes )
Expand Down Expand Up @@ -246,6 +246,9 @@ getMeta [] = ""
parseYaml :: String -> [Node]
parseYaml = parseStream . buildTree . tokenize "-"

makeTokens = tokenize "-"
makeTree = buildTree . tokenize "-"

parseYamlList :: String -> [Node]
parseYamlList x = case parseYaml x of
[List ns] -> ns
Expand Down
12 changes: 9 additions & 3 deletions yamltest.hs
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
module Main where

import YAML ( parseYamlList )
import YAML ( parseYamlList, parseYaml, makeTree, makeTokens )

main :: IO ()
main = do let partialstring = unlines ["- foo","- bar",undefined]
main = do let partialstring = unlines ["- foo","- bar" --, undefined
]
putStrLn "The partialstring has two defined elements:"
print $ take 2 $ lines partialstring
putStrLn "makeTokens should find those two elements:"
mapM_ print $ makeTokens partialstring
putStrLn "makeTree should find those two elements:"
mapM_ print $ makeTree partialstring
putStrLn "parseYamlList should find those two elements:"
print $ take 2 $ parseYamlList partialstring
mapM_ print $ parseYaml partialstring
print $ take 1 $ parseYamlList partialstring
putStrLn "You may now play with parseYamlList interactively:"
x <- parseYamlList `fmap` getContents
mapM_ print x

0 comments on commit 5820fc9

Please sign in to comment.