NoHoed (empty) → 0.1.0
raw patch · 3 files changed
+118/−0 lines, 3 filesdep +base
Dependencies added: base
Files
- LICENSE +29/−0
- NoHoed.cabal +25/−0
- src/Debug/Hoed/Pure.hs +64/−0
+ LICENSE view
@@ -0,0 +1,29 @@+BSD 3-Clause License++Copyright (c) 2017, Pepe Iborra+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++* Redistributions of source code must retain the above copyright notice, this+ list of conditions and the following disclaimer.++* Redistributions in binary form must reproduce the above copyright notice,+ this list of conditions and the following disclaimer in the documentation+ and/or other materials provided with the distribution.++* Neither the name of the copyright holder nor the names of its+ contributors may be used to endorse or promote products derived from+ this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ NoHoed.cabal view
@@ -0,0 +1,25 @@+-- This file has been generated from package.yaml by hpack version 0.17.1.+--+-- see: https://github.com/sol/hpack++name: NoHoed+version: 0.1.0+synopsis: Placeholder package to preserve debug ability via conditional builds+category: Debugging+homepage: https://github.com/pepeiborra/NoHoed+author: Jose Iborra+maintainer: pepeiborra@gmail.com+copyright: All Rights Reserved+license: BSD3+license-file: LICENSE+build-type: Simple+cabal-version: >= 1.10++library+ hs-source-dirs:+ src+ build-depends:+ base < 5+ exposed-modules:+ Debug.Hoed.Pure+ default-language: Haskell2010
+ src/Debug/Hoed/Pure.hs view
@@ -0,0 +1,64 @@+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE RankNTypes #-}+-- | This module exports noop but type compatible versions of the+-- most common combinators from the Hoed package.+-- It is designed to be used in conjunction with Cabal flags to+-- preserve the ability to debug a program without the overhead.+module Debug.Hoed.Pure+ (+ observe+ , observeBase+ , observeOpaque+ , constrainBase+ , send+ , runO+ , printO+ , Observable(..)+ , Observer(..)+ , (<<)+ , Generic+ ) where++import Control.Monad+import Data.Functor.Identity+import GHC.Generics++observe :: String -> a -> a+observe _ x = x++runO :: IO a -> IO ()+runO = void++printO :: (Show a) => a -> IO ()+printO expr = runO (print expr)++infixl 9 <<++class Observable a where+ observer :: a -> b -> a+ observer a _ = a+ constrain :: a -> a -> a+ constrain a b = a++instance {-# OVERLAPPABLE #-} Observable a++newtype Observer = O (forall a . (Observable a) => String -> a -> a)++newtype ObserverM a = ObserverM { runMO :: Identity a}+ deriving (Functor, Applicative, Monad)++(<<) :: (Observable a) => ObserverM (a -> b) -> a -> ObserverM b+fn << a = fn <*> pure a++observeBase :: a -> parent -> a+observeBase = const++constrainBase :: a -> a -> a+constrainBase = const++observeOpaque :: String -> a -> parent -> a+observeOpaque _ val _ = val++send :: String -> ObserverM a -> parent -> a+send _ a _ = runIdentity $ runMO a