-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert to expression level coverage (incomplete), refactoring and in…
…troduction of Json module
- Loading branch information
Showing
6 changed files
with
69 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
-- | | ||
-- Module: Trace.Hpc.Json | ||
-- Copyright: (c) 2014-2015 Guillaume Nargeot | ||
-- License: BSD3 | ||
-- Maintainer: Guillaume Nargeot <guillaume+hackage@nargeot.com> | ||
-- Stability: experimental | ||
-- | ||
-- Functions for generating the core coverage data in the json format defined by codecov.io | ||
|
||
module Trace.Hpc.Codecov.Json ( defaultConverter ) where | ||
|
||
import Control.Arrow (first) | ||
import Data.Aeson | ||
import Data.Aeson.Types () | ||
import Data.Maybe | ||
import qualified Data.Vector as V | ||
import Trace.Hpc.Codecov.Types | ||
|
||
convHit :: Hit -> Value | ||
convHit hit = case hit of | ||
Full -> Number 1 | ||
Partial -> Bool True | ||
None -> Number 0 | ||
Irrelevant -> Null | ||
|
||
convArray :: [Value] -> Value | ||
convArray = Array . V.fromList | ||
|
||
convTuple :: (Value, (Int, Int)) -> Value | ||
convTuple (hit, (start, end)) = convArray [toVal start, toVal end, hit] | ||
where toVal = Number . fromIntegral | ||
|
||
convExpr :: [ExprHit] -> Value | ||
convExpr = convArray . map (convTuple . first convHit) | ||
|
||
defaultConverter :: LixConverter | ||
defaultConverter = map (convLine . fmap convExpr) | ||
where convLine = fromMaybe Null | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters