packages feed

keiro-dsl-0.18.0.0: test/conformance-checked-mapping-replay/Generated/CheckedMappingReplay/BehaviorSourceMap.hs

-- @generated by keiro-dsl 0.18.0.0 (language keiro-dsl 6) from context checked-mapping-replay behavior source map; do not edit.
module Generated.CheckedMappingReplay.BehaviorSourceMap
  ( BehaviorSourceLocation (..)
  , behaviorSourceLocation
  , renderBehaviorSourceLocation
  ) where

import Data.Text (Text)
import Data.Text qualified as T

data BehaviorSourceLocation = BehaviorSourceLocation
  { file :: !FilePath
  , line :: !Int
  , column :: !Int
  }
  deriving stock (Eq, Ord, Show)

behaviorSourceLocation :: Text -> Maybe BehaviorSourceLocation
behaviorSourceLocation key = case key of
  "behavior-v1-00d5b6d8d0fc6ef2" -> Just (BehaviorSourceLocation "domain/service.keiro" 23 3)
  "behavior-v1-756d75346570c343" -> Just (BehaviorSourceLocation "domain/service.keiro" 39 3)
  "behavior-v1-9846660db9e83048" -> Just (BehaviorSourceLocation "domain/service.keiro" 8 10)
  "behavior-v1-cf9c72cd877a5085" -> Just (BehaviorSourceLocation "domain/service.keiro" 16 3)
  "behavior-v1-e88b4f5c37ef8bf2" -> Just (BehaviorSourceLocation "domain/service.keiro" 8 16)
  "behavior-v1-efa5614712549991" -> Just (BehaviorSourceLocation "domain/service.keiro" 8 16)
  _ -> Nothing

renderBehaviorSourceLocation :: Text -> Text
renderBehaviorSourceLocation key = case behaviorSourceLocation key of
  Just location -> T.pack location.file <> ":" <> tshow location.line <> ":" <> tshow location.column
  Nothing -> "<internal invariant: missing behavior source for " <> key <> ">"

tshow :: Show value => value -> Text
tshow = T.pack . show