{-# LANGUAGE TemplateHaskell, TypeFamilies #-}

{- |

Module      :  Type.Serialize
Copyright   :  (c) The University of Kansas 2011
License     :  BSD3

Maintainer  :  nicolas.frisby@gmail.com
Stability   :  experimental
Portability :  see LANGUAGE pragmas (... GHC)

Type-level serialization for the basic types (Bool, Char, Either, etc.) as well
as the @type-spine@ default case for type-applications.

-}
module Type.Serialize (module Type.Serialize.Base) where

import Type.Serialize.Base

import Type.Spine.Stage0 (kTypeG)
import Language.Haskell.TH
import Type.Digits (toType_, digit, radix)



fmap concat $ mapM serializeTypeAsHash
  [''Bool, ''Char, ''Double, ''Float, ''Int, ''Integer, ''Ordering,
   ''(), ''(,), ''(,,), ''(,,,), ''(,,,,),
   ''IO, ''[], ''Maybe, ''(->), ''Either]


sequence [
 let k2 = kTypeG $ ArrowK StarK StarK
     n = conT $ digit d
     v = return $ toType_ [digit d]
 in tySynInstD ''Serialize [k2 `appT` n] v
 | d <- [0..radix-1]]