module Data.Repa.Nice
( Nicer (..)
, Str (..)
, Tok (..))
where
import Data.Repa.Array.Generic as A
import Data.Repa.Product as B
import Control.Monad
import Data.Word
import Data.Int
import Prelude as P
data Str = Str [Char]
instance Show Str where
show (Str xs) = show xs
data Tok = Tok [Char]
instance Show Tok where
show (Tok xs) = xs
class Nicer a where
type Nice a
nice :: a -> Nice a
instance Nicer () where
type Nice () = ()
nice x = x
instance Nicer Char where
type Nice Char = Char
nice x = x
instance Nicer Float where
type Nice Float = Float
nice x = x
instance Nicer Double where
type Nice Double = Double
nice x = x
instance Nicer Int where
type Nice Int = Int
nice x = x
instance Nicer Int8 where
type Nice Int8 = Int8
nice x = x
instance Nicer Int16 where
type Nice Int16 = Int16
nice x = x
instance Nicer Int32 where
type Nice Int32 = Int32
nice x = x
instance Nicer Int64 where
type Nice Int64 = Int64
nice x = x
instance Nicer Word where
type Nice Word = Word
nice x = x
instance Nicer Word8 where
type Nice Word8 = Word8
nice x = x
instance Nicer Word16 where
type Nice Word16 = Word16
nice x = x
instance Nicer Word32 where
type Nice Word32 = Word32
nice x = x
instance Nicer Word64 where
type Nice Word64 = Word64
nice x = x
instance Nicer [Char] where
type Nice [Char] = Str
nice xs = Str xs
instance Nicer [Int] where
type Nice [Int] = [Int]
nice xs = xs
instance Nicer [Float] where
type Nice [Float] = [Float]
nice xs = xs
instance Nicer [Double] where
type Nice [Double] = [Double]
nice xs = xs
instance Nicer [Int8] where
type Nice [Int8] = [Int8]
nice xs = xs
instance Nicer [Int16] where
type Nice [Int16] = [Int16]
nice xs = xs
instance Nicer [Int32] where
type Nice [Int32] = [Int32]
nice xs = xs
instance Nicer [Int64] where
type Nice [Int64] = [Int64]
nice xs = xs
instance Nicer [Word8] where
type Nice [Word8] = [Word8]
nice xs = xs
instance Nicer [Word16] where
type Nice [Word16] = [Word16]
nice xs = xs
instance Nicer [Word32] where
type Nice [Word32] = [Word32]
nice xs = xs
instance Nicer [Word64] where
type Nice [Word64] = [Word64]
nice xs = xs
instance Nicer a
=> Nicer (Maybe a) where
type Nice (Maybe a) = Maybe (Nice a)
nice x = liftM nice x
instance (Nicer a, Nicer b)
=> Nicer (a, b) where
type Nice (a, b) = (Nice a, Nice b)
nice (x, y) = (nice x, nice y)
instance (Nicer a, Nicer b)
=> Nicer (a :*: b) where
type Nice (a :*: b) = (Nice a :*: Nice b)
nice (x :*: y) = (nice x :*: nice y)
instance (Bulk l a, Nicer [a])
=> Nicer (Array l a) where
type Nice (Array l a) = Nice [a]
nice vec = nice $ toList vec
instance Nicer a
=> Nicer [Maybe a] where
type Nice [Maybe a] = [Nice (Maybe a)]
nice xs = P.map nice xs
instance (Nicer a, Nicer b)
=> Nicer [(a, b)] where
type Nice [(a, b)] = [Nice (a, b)]
nice xs = P.map nice xs
instance (Nicer a, Nicer b)
=> Nicer [(a :*: b)] where
type Nice [(a :*: b)] = [Nice (a :*: b)]
nice xs = P.map nice xs
instance (Bulk l a, Nicer [a])
=> Nicer [(Array l a)] where
type Nice [Array l a] = [Nice [a]]
nice xs = P.map (nice . toList) xs
instance Nicer [a]
=> Nicer [[a]] where
type Nice [[a]] = [Nice [a]]
nice xs = P.map nice xs