mirror of
https://github.com/github/semantic.git
synced 2024-12-30 10:27:45 +03:00
Define a Show1 instance for IntMap-based Table.
This commit is contained in:
parent
216381fb4c
commit
6929b6955d
@ -1,6 +1,7 @@
|
||||
module Data.Syntax.Assignment.Table.IntMap where
|
||||
|
||||
import Data.Bifunctor (first)
|
||||
import Data.Functor.Classes
|
||||
import qualified Data.IntMap as IntMap
|
||||
|
||||
data Table i a = Table { tableAddresses :: [i], tableBranches :: IntMap.IntMap a }
|
||||
@ -18,3 +19,7 @@ toList Table{..} = first toEnum <$> IntMap.toList tableBranches
|
||||
|
||||
lookup :: Enum i => i -> Table i a -> Maybe a
|
||||
lookup i = IntMap.lookup (fromEnum i) . tableBranches
|
||||
|
||||
|
||||
instance (Enum i, Show i) => Show1 (Table i) where
|
||||
liftShowsPrec spA slA d t = showsBinaryWith showsPrec (const (liftShowList spA slA)) "Table" d (tableAddresses t) (toList t)
|
||||
|
Loading…
Reference in New Issue
Block a user