{-# OPTIONS_GHC -fno-warn-orphans #-}

module Data.Validity.Tree where

import Data.Validity

import Data.Tree

-- | A 'Tree' of things is valid if all the things in the 'Tree' are valid.
instance Validity a => Validity (Tree a) where
    validate :: Tree a -> Validation
validate (Node rl :: a
rl sf :: Forest a
sf) =
        [Validation] -> Validation
forall a. Monoid a => [a] -> a
mconcat [a -> String -> Validation
forall a. Validity a => a -> String -> Validation
annotate a
rl "rootLabel", Forest a -> String -> Validation
forall a. Validity a => a -> String -> Validation
annotate Forest a
sf "subForest"]