module Data.Repa.Convert.Format.Ascii
(FormatAscii (..))
where
import Data.Repa.Convert.Format.Numeric
import Data.Repa.Convert.Format.String
import Data.Repa.Convert.Format.Date32
import Data.Repa.Scalar.Date32 (Date32)
import Data.Repa.Scalar.Product
#include "repa-convert.h"
class FormatAscii a where
type FormatAscii' a
formatAscii :: a -> FormatAscii' a
data Plain a
= Plain a
instance FormatAscii () where
type FormatAscii' () = ()
formatAscii _ = ()
{-# INLINE formatAscii #-}
instance FormatAscii (Plain ()) where
type FormatAscii' (Plain ()) = ()
formatAscii (Plain _) = ()
{-# INLINE formatAscii #-}
instance (FormatAscii t1, FormatAscii (Plain ts))
=> FormatAscii (Plain (t1 :*: ts)) where
type FormatAscii' (Plain (t1 :*: ts))
= FormatAscii' t1 :*: FormatAscii' (Plain ts)
formatAscii _
= let
(x1_proxy :: t1) = error "repa-convert: formatAscii proxy"
(xs_proxy :: ts) = error "repa-convert: formatAscii proxy"
in formatAscii x1_proxy :*: formatAscii (Plain xs_proxy)
{-# NOINLINE formatAscii #-}
instance FormatAscii Int where
type FormatAscii' Int = IntAsc
formatAscii _ = IntAsc
{-# INLINE formatAscii #-}
instance FormatAscii Double where
type FormatAscii' Double = DoubleAsc
formatAscii _ = DoubleAsc
{-# INLINE formatAscii #-}
instance FormatAscii String where
type FormatAscii' String = VarCharString
formatAscii _ = VarCharString
{-# INLINE formatAscii #-}
instance FormatAscii Date32 where
type FormatAscii' Date32 = YYYYsMMsDD
formatAscii _ = YYYYsMMsDD '-'
{-# INLINE formatAscii #-}