-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Lightweight algorithmic debugging. -- -- Hoed is a tracer and debugger for the programming language Haskell. -- -- To locate a defect with Hoed you annotate suspected functions and -- compile as usual. Then you run your program, information about the -- annotated functions is collected. Finally you connect to a debugging -- session using a webbrowser. @package Hoed @version 0.4.0 -- | Hoed is a tracer and debugger for the programming language Haskell. -- -- This is a drop-in replacement of the Debug.Hoed.Pure or Debug.Hoed.Stk -- modules and disables tracing (all functions are variations of id). -- -- Read more about Hoed on its project homepage -- https://wiki.haskell.org/Hoed. -- -- Papers on the theory behind Hoed can be obtained via -- http://maartenfaddegon.nl/#pub. -- -- I am keen to hear about your experience with Hoed: where did you find -- it useful and where would you like to see improvement? You can send me -- an e-mail at hoed@maartenfaddegon.nl, or use the github issue tracker -- https://github.com/MaartenFaddegon/hoed/issues. module Debug.NoHoed observe :: String -> a -> a runO :: IO a -> IO () printO :: (Show a) => a -> IO () testO :: Show a => (a -> Bool) -> a -> IO () observeBase :: a -> Parent -> a class Observable a where observer x _ = x constrain x _ = x observer :: Observable a => a -> Parent -> a observer :: (Observable a, Generic a) => a -> Parent -> a constrain :: Observable a => a -> a -> a constrain :: (Observable a, Generic a) => a -> a -> a data Parent Parent :: Parent -- | Representable types of kind *. This class is derivable in GHC with the -- DeriveGeneric flag on. class Generic a where type Rep a :: * -> * where { type family Rep a :: * -> *; } -- | Convert from the datatype to its representation from :: Generic a => a -> Rep a x -- | Convert from the representation to the datatype to :: Generic a => Rep a x -> a send :: String -> ObserverM a -> Parent -> a newtype ObserverM a ObserverM :: (Int -> Int -> (a, Int)) -> ObserverM a [runMO] :: ObserverM a -> Int -> Int -> (a, Int) (<<) :: (Observable a) => ObserverM (a -> b) -> a -> ObserverM b instance GHC.Base.Functor Debug.NoHoed.ObserverM instance GHC.Base.Applicative Debug.NoHoed.ObserverM instance GHC.Base.Monad Debug.NoHoed.ObserverM instance Debug.NoHoed.Observable GHC.Types.Int instance Debug.NoHoed.Observable GHC.Types.Bool instance Debug.NoHoed.Observable GHC.Integer.Type.Integer instance Debug.NoHoed.Observable GHC.Types.Float instance Debug.NoHoed.Observable GHC.Types.Double instance Debug.NoHoed.Observable GHC.Types.Char instance Debug.NoHoed.Observable () instance Debug.NoHoed.Observable a => Debug.NoHoed.Observable [a] -- | Hoed is a tracer and debugger for the programming language Haskell. -- -- Hoed is recommended over Hoed.Stk: in contrast to Hoed.Stk you can -- optimize your program and do not need to enable profiling when using -- Hoed. -- -- To locate a defect with Hoed you annotate suspected functions and -- compile as usual. Then you run your program, information about the -- annotated functions is collected. Finally you connect to a debugging -- session using a webbrowser. -- -- Let us consider the following program, a defective implementation of a -- parity function with a test property. -- --
--   import Test.QuickCheck
--   
--   isOdd :: Int -> Bool
--   isOdd n = isEven (plusOne n)
--   
--   isEven :: Int -> Bool
--   isEven n = mod2 n == 0
--   
--   plusOne :: Int -> Int
--   plusOne n = n + 1
--   
--   mod2 :: Int -> Int
--   mod2 n = div n 2
--   
--   prop_isOdd :: Int -> Bool
--   prop_isOdd x = isOdd (2*x+1)
--   
--   main :: IO ()
--   main = printO (prop_isOdd 1)
--   
--   main :: IO ()
--   main = quickcheck prop_isOdd
--   
-- -- Using the property-based test tool QuickCheck we find the counter -- example `1` for our property. -- --
--   ./MyProgram
--   *** Failed! Falsifiable (after 1 test): 1
--   
-- -- Hoed can help us determine which function is defective. We annotate -- the functions isOdd, isEven, plusOne and -- mod2 as follows: -- --
--   import Debug.Hoed
--   
--   isOdd :: Int -> Bool
--   isOdd = observe "isOdd" isOdd'
--   isOdd' n = isEven (plusOne n)
--   
--   isEven :: Int -> Bool
--   isEven = observe "isEven" isEven'
--   isEven' n = mod2 n == 0
--   
--   plusOne :: Int -> Int
--   plusOne = observe "plusOne" plusOne'
--   plusOne' n = n + 1
--   
--   mod2 :: Int -> Int
--   mod2 = observe "mod2" mod2'
--   mod2' n = div n 2
--   
--   prop_isOdd :: Int -> Bool
--   prop_isOdd x = isOdd (2*x+1)
--   
--   main :: IO ()
--   main = printO (prop_isOdd 1)
--   
-- -- After running the program a computation tree is constructed and -- displayed in a web browser. -- --
--   ./MyProgram
--   False
--   Listening on http://127.0.0.1:10000/
--   
-- -- After running the program a computation tree is constructed and -- displayed in a web browser. You can freely browse this tree to get a -- better understanding of your program. If your program misbehaves, you -- can judge the computation statements in the tree as right or -- wrong according to your intention. When enough statements are -- judged the debugger tells you the location of the fault in your code. -- -- -- Read more about Hoed on its project homepage -- https://wiki.haskell.org/Hoed. -- -- Papers on the theory behind Hoed can be obtained via -- http://maartenfaddegon.nl/#pub. -- -- I am keen to hear about your experience with Hoed: where did you find -- it useful and where would you like to see improvement? You can send me -- an e-mail at hoed@maartenfaddegon.nl, or use the github issue tracker -- https://github.com/MaartenFaddegon/hoed/issues. module Debug.Hoed -- | Functions which you suspect of misbehaving are annotated with observe -- and should have a cost centre set. The name of the function, the label -- of the cost centre and the label given to observe need to be the same. -- -- Consider the following function: -- --
--   triple x = x + x
--   
-- -- This function is annotated as follows: -- --
--   triple y = (observe "triple" (\x -> {# SCC "triple" #}  x + x)) y
--   
-- -- To produce computation statements like: -- --
--   triple 3 = 6
--   
-- -- To observe a value its type needs to be of class Observable. We -- provided instances for many types already. If you have defined your -- own type, and want to observe a function that takes a value of this -- type as argument or returns a value of this type, an Observable -- instance can be derived as follows: -- --
--   data MyType = MyNumber Int | MyName String deriving Generic
--   
--   instance Observable MyType
--   
observe :: (Observable a) => String -> a -> a -- | The main entry point; run some IO code, and debug inside it. After the -- IO action is completed, an algorithmic debugging session is started at -- http://localhost:10000/ to which you can connect with -- your webbrowser. -- -- For example: -- --
--   main = runO $ do print (triple 3)
--                    print (triple 2)
--   
runO :: IO a -> IO () -- | Short for runO . print. printO :: (Show a) => a -> IO () -- | Repeat and trace a failing testcase testO :: Show a => (a -> Bool) -> a -> IO () -- | Use property based judging. runOwp :: [Propositions] -> IO a -> IO () printOwp :: (Show a) => [Propositions] -> a -> IO () -- | Repeat and trace a failing testcase testOwp :: Show a => [Propositions] -> (a -> Bool) -> a -> IO () data Propositions Propositions :: [Proposition] -> PropType -> String -> [Module] -> Propositions [propositions] :: Propositions -> [Proposition] [propType] :: Propositions -> PropType [funName] :: Propositions -> String [extraModules] :: Propositions -> [Module] data PropType Specify :: PropType PropertiesOf :: PropType data Proposition Proposition :: PropositionType -> Module -> String -> [Signature] -> Maybe Int -> TestGen -> Proposition [propositionType] :: Proposition -> PropositionType [propModule] :: Proposition -> Module [propName] :: Proposition -> String [signature] :: Proposition -> [Signature] [maxSize] :: Proposition -> Maybe Int [testgen] :: Proposition -> TestGen mkProposition :: Module -> String -> Proposition ofType :: Proposition -> PropositionType -> Proposition withSignature :: Proposition -> [Signature] -> Proposition sizeHint :: Proposition -> Int -> Proposition withTestGen :: Proposition -> TestGen -> Proposition data TestGen TestGenQuickCheck :: TestGen TestGenLegacyQuickCheck :: TestGen data PropositionType IOProposition :: PropositionType BoolProposition :: PropositionType LegacyQuickCheckProposition :: PropositionType QuickCheckProposition :: PropositionType data Module Module :: String -> String -> Module [moduleName] :: Module -> String [searchPath] :: Module -> String data Signature Argument :: Int -> Signature SubjectFunction :: Signature Random :: Signature class ParEq a where parEq x y = gParEq (from x) (from y) parEq :: ParEq a => a -> a -> Maybe Bool parEq :: (ParEq a, Generic a, GParEq (Rep a)) => a -> a -> Maybe Bool (===) :: ParEq a => a -> a -> Bool -- | Hoed internal function that stores a serialized version of the tree on -- disk (assisted debugging spawns new instances of Hoed). runOstore :: String -> IO a -> IO () conAp :: Observable b => (a -> b) -> b -> a -> b -- | Entry point giving you access to the internals of Hoed. Also see: -- runO. runO' :: Verbosity -> IO a -> IO (Trace, TraceInfo, CompTree, EventForest) -- | Use propositions to judge a computation statement. First tries -- restricted and bottom for unevaluated expressions, then unrestricted, -- and finally with randomly generated values for unevaluated -- expressions. judge :: Trace -> Propositions -> Vertex -> (CompTree -> Int) -> CompTree -> IO Judge -- | Approximates the complexity of a computation tree by summing the -- length of the unjudged computation statements (i.e not Right or Wrong) -- in the tree. unjudgedCharacterCount :: CompTree -> Int -- | The forest of computation trees. Also see the Libgraph library. type CompTree = Graph Vertex () data Vertex RootVertex :: Vertex Vertex :: CompStmt -> Judgement -> Vertex [vertexStmt] :: Vertex -> CompStmt [vertexJmt] :: Vertex -> Judgement data CompStmt CompStmt :: String -> UID -> String -> CompStmt [stmtLabel] :: CompStmt -> String [stmtIdentifier] :: CompStmt -> UID [stmtRes] :: CompStmt -> String data Judge -- | Returns a Judgement (see Libgraph library). Judge :: Judgement -> Judge -- | Found counter example with simpler computation tree. AlternativeTree :: CompTree -> Trace -> Judge data Verbosity Verbose :: Verbosity Silent :: Verbosity -- | Trace and write computation tree to file. Useful for regression -- testing. logO :: FilePath -> IO a -> IO () -- | As logO, but with property-based judging. logOwp :: UnevalHandler -> FilePath -> [Propositions] -> IO a -> IO () -- | Only produces a trace. Useful for performance measurements. traceOnly :: IO a -> IO () data UnevalHandler RestrictedBottom :: UnevalHandler Bottom :: UnevalHandler Forall :: UnevalHandler FromList :: [String] -> UnevalHandler newtype Observer O :: (forall a. (Observable a) => String -> a -> a) -> Observer class Observable a where observer x c = to (gdmobserver (from x) c) constrain x c = to (gconstrain (from x) (from c)) observer :: Observable a => a -> Parent -> a observer :: (Observable a, Generic a, GObservable (Rep a)) => a -> Parent -> a constrain :: Observable a => a -> a -> a constrain :: (Observable a, Generic a, GConstrain (Rep a)) => a -> a -> a (<<) :: (Observable a) => ObserverM (a -> b) -> a -> ObserverM b infixl 9 << thunk :: (a -> Parent -> a) -> a -> ObserverM a nothunk :: a -> ObserverM a send :: String -> ObserverM a -> Parent -> a observeOpaque :: String -> a -> Parent -> a observeBase :: (Show a) => a -> Parent -> a constrainBase :: (Show a, Eq a) => a -> a -> a -- | run some code and return the Trace debugO :: IO a -> IO Trace data CDS -- | Representable types of kind *. This class is derivable in GHC with the -- DeriveGeneric flag on. class Generic a