1
1
mirror of https://github.com/github/semantic.git synced 2024-12-29 09:55:52 +03:00

Define a Show1 instance for Table.

This commit is contained in:
Rob Rix 2017-08-31 22:29:42 -04:00
parent 207db7c0a1
commit ea01aa9e2b

View File

@ -3,5 +3,11 @@ module Data.Syntax.Assignment.Table.Array
) where
import Data.Array
import Data.Foldable (toList)
import Data.Functor.Classes
data Table i a = Table { tableAddresses :: [i], tableBranches :: Array i (Maybe a) }
instance (Ix i, Show i) => Show1 (Table i) where
liftShowsPrec spA slA d Table{..} = showsBinaryWith showsPrec (const (liftShowList spA slA)) "Table" d tableAddresses (assocs tableBranches >>= \ (sym, a) -> (,) sym <$> toList a)