packages feed

kure-2.18.6: Language/KURE/Debug.hs

-- |
-- Module: Language.KURE.Debug
-- Copyright: (c) 2012--2021 The University of Kansas
-- License: BSD3
--
-- Maintainer: Neil Sculthorpe <neil.sculthorpe@ntu.ac.uk>
-- Stability: beta
-- Portability: ghc
--
-- This module provides (unsafe) debugging/tracing combinators.
--
module Language.KURE.Debug (
        debugR
) where

import Control.Monad.Fail
import Debug.Trace

import Language.KURE.Combinators.Transform
import Language.KURE.Transform


-- | Trace output of the value being rewritten; use for debugging only.
debugR :: (MonadFail m, Show a) => Int -> String -> Rewrite c m a
debugR n msg = acceptR (\ a -> trace (msg ++ " : " ++ take n (show a)) True)