packages feed

keiro-dsl-0.18.0.0: test/conformance-refined-base16/Generated/RefinedBase16/BehaviorSourceMap.hs

-- @generated by keiro-dsl 0.18.0.0 (language keiro-dsl 6) from context refined-base16 behavior source map; do not edit.
module Generated.RefinedBase16.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-3506774d4ee392a3" -> Just (BehaviorSourceLocation "keiro-dsl/test/fixtures/refined-base16.keiro" 49 3)
  "behavior-v1-48110d655c1ffd6d" -> Just (BehaviorSourceLocation "keiro-dsl/test/fixtures/refined-base16.keiro" 41 16)
  "behavior-v1-9838f2b4bff837a3" -> Just (BehaviorSourceLocation "keiro-dsl/test/fixtures/refined-base16.keiro" 41 10)
  "behavior-v1-bf6e600d5467e6cc" -> Just (BehaviorSourceLocation "keiro-dsl/test/fixtures/refined-base16.keiro" 41 16)
  "behavior-v1-ec86c76d09301c82" -> Just (BehaviorSourceLocation "keiro-dsl/test/fixtures/refined-base16.keiro" 55 3)
  _ -> 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