-----------------------------------------------------------------------------
--
-- Module      :  Data.Table.Identifier
-- Copyright   :  (c) 2014-16 Brian W Bush
-- License     :  MIT
--
-- Maintainer  :  Brian W Bush <consult@brianwbush.info>
-- Stability   :  Experimental
-- Portability :  Portable
--
-- | Identifier for use in tables.
--
-----------------------------------------------------------------------------


{-# LANGUAGE FlexibleInstances         #-}

{-# OPTIONS_GHC -fno-warn-deprecations #-}


module Data.Table.Identifier {-# DEPRECATED "This module will be replaced in a future release." #-} (
-- * Types
  Id(..)
) where


import Data.Table (Tabulatable(..))


-- | An identifier for a table.
newtype Id a = Id {unId :: a}
  deriving (Read, Show)

instance Tabulatable (Id String) where
  labels = const ["ID"]
  tabulation = (: []) . unId
  untabulation = Id . head

instance (Read a, Show a) => Tabulatable (Id a) where
  labels = const ["ID"]
  tabulation = (: []) . show . unId
  untabulation = Id . read . head