Permalink
Browse files

Add debug utility

  • Loading branch information...
1 parent 93079fa commit 8155062bb65f401a2eef396c53038b9be5197514 @jaspervdj committed Dec 23, 2012
@@ -45,18 +45,19 @@ Library
Hs-source-dirs: src
Ghc-options: -Wall -fwarn-tabs
- Exposed-modules:
+ Exposed-modules:
Text.Digestive
Text.Digestive.Form
Text.Digestive.Form.Encoding
Text.Digestive.Ref
Text.Digestive.Types
Text.Digestive.Util
Text.Digestive.View
+ Text.Digestive.Form.Internal
Other-modules:
+ -- TODO make this exposed in some way
Text.Digestive.Field
- Text.Digestive.Form.Internal
Build-depends:
base >= 4 && < 5,
@@ -22,6 +22,9 @@ module Text.Digestive.Form.Internal
, queryField
, eval
, formMapView
+
+ -- * Debugging
+ , debugFormPaths
) where
@@ -270,3 +273,13 @@ bindResult mx f = do
case x of
Error errs -> return $ Error errs
Success x' -> f x'
+
+
+--------------------------------------------------------------------------------
+-- | Debugging purposes
+debugFormPaths :: Monad m => FormTree Identity v m a -> [Path]
+debugFormPaths (Pure _) = [[]]
+debugFormPaths (App x y) = debugFormPaths x ++ debugFormPaths y
+debugFormPaths (Map _ x) = debugFormPaths x
+debugFormPaths (Monadic x) = debugFormPaths $ runIdentity x
+debugFormPaths (Ref r x) = map (r :) $ debugFormPaths x

0 comments on commit 8155062

Please sign in to comment.