-- | Tracing execution of Feldspar expressions

module Feldspar.Core.Functions.Trace where

import Feldspar.Core.Types
import Feldspar.Core.Representation
import Feldspar.Core.Constructs
import Feldspar.Core.Functions.Num

-- | Tracing execution of an expression. Semantically, this is the identity
-- function, but a back end may treat this function specially, for example write
-- its arguments to a log.
trace :: Numeric a => Int -> Data a -> Data a
trace label = function2 "trace" (const id) (const id) label'
    label' = fromIntegral label :: Data DefaultInt