File: Show.hs

package info (click to toggle)
bali-phy 4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 15,392 kB
  • sloc: cpp: 120,442; xml: 13,966; haskell: 9,975; python: 2,936; yacc: 1,328; perl: 1,169; lex: 912; sh: 343; makefile: 26
file content (43 lines) | stat: -rw-r--r-- 1,178 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{-# LANGUAGE NoImplicitPrelude #-}
module Text.Show where

import Foreign.String
import Data.List
import Data.Function

class Show a where
    show :: a -> [Char]
    showList :: [a] -> [Char]

    showList [] = "[]"
    showList (x:y) = "["++show x++show' y++"]" where show' [] = ""
                                                     show' (x:y) = ","++show x++show' y

instance Show Char where
    show  c = ['\'',c,'\'']
    showList s = "\"" ++ s ++ "\""

instance Show Int where
    show i = unpack_cpp_string $ show_int i

instance Show Integer where
    show i = unpack_cpp_string $ show_integer i

instance Show Double where
    show  d = unpack_cpp_string $ show_double d

instance Show () where
    show _ = "()"

instance (Show a, Show b) => Show (a,b) where
    show (x,y) = "(" ++ show x ++ "," ++ show y ++ ")"

instance (Show a, Show b, Show c) => Show (a,b,c) where
    show (x,y,z) = "(" ++ show x ++ "," ++ show y ++ "," ++ show z ++ ")"

instance (Show a, Show b, Show c, Show d) => Show (a,b,c,d) where
    show (x,y,z,w) = "(" ++ show x ++ "," ++ show y ++ "," ++ show z ++ "," ++ show w ++ ")"

instance Show a => Show [a] where
    show s = showList s