packages feed

haskell-gha-1.0: tests/HaskellGha/Test/Helpers.hs

module HaskellGha.Test.Helpers (normalize) where

import Yamlet.Syntax

-- | Remove the positions and the comments, and give every collection the block
-- style, as the renderer writes it. A parsed node then compares equal to a
-- built one.
normalize :: Node -> Node
normalize n =
  Node
    { offset = noOffset
    , endOffset = noOffset
    , props = n.props
    , comments = noComments
    , content = case n.content of
        SequenceContent _ xs -> SequenceContent Block (map normalize xs)
        MappingContent _ kvs ->
          MappingContent Block [(normalize k, normalize v) | (k, v) <- kvs]
        c -> c
    }