Commit 24fccdb7 authored by Tim Steenvoorden's avatar Tim Steenvoorden
Browse files

add instances for Show for basic types

parent db31b8d8
......@@ -24,7 +24,7 @@ Global
Time: False
Stack: False
Output
Output: BasicValuesOnly
Output: ShowConstructors
Font: Monaco
FontSize: 9
WriteStdErr: False
......@@ -267,6 +267,20 @@ OtherModules
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
Module
Name: Text.Show
Dir: {Project}/src
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
Module
Name: _SystemArray
Dir: {Application}/lib/StdEnv
......
......@@ -19,7 +19,7 @@ import Algebra.Group
import Algebra.Ring
import Algebra.Lattice
// import Text.Show
import Text.Show
// import System.Console
// import System.File
......
......@@ -14,4 +14,4 @@ c = {1, 2}
d :: {#Int}
d = {1, 2}
Start = a == b
Start = ((show a, show 4), (a,c))
......@@ -280,39 +280,13 @@ prim_writeStringFile s f = code inline {
/// ## Booleans
prim_boolToString :: !Bool -> String
prim_boolToString b = code inline {
.d 0 1 b
jsr BtoAC
.o 1 0
}
/// ## Characters
prim_charToString :: !Char -> String
prim_charToString c = code inline {
CtoAC
}
/// ## Integers
prim_intToString :: !Int -> String
prim_intToString i = code inline {
.d 0 1 i
jsr ItoAC
.o 1 0
}
/// ## Reals
prim_realToInt :: !Real -> Int
prim_realToInt x = code inline {
RtoI
}
prim_realToString :: !Real -> String
prim_realToString x = code inline {
.d 0 2 r
jsr RtoAC
.o 1 0
}
......@@ -3,6 +3,8 @@ system module Data.Array.Unboxed
from Algebra.Order import class Eq, class Ord
from Algebra.Group import class Semigroup, class Monoid
from Text.Show import class Show
import _SystemArray
/// # Definition
......@@ -12,6 +14,12 @@ import _SystemArray
/// # Instances
// instance Show {#Bool}
instance Show {#Char}
// instance Show {#Nat}
// instance Show {#Int}
// instance Show {#Real}
// instance Eq {#Bool}
instance Eq {#Char}
// instance Eq {#Nat}
......
......@@ -5,10 +5,17 @@ import Data.Function
import Algebra.Order
import Algebra.Group
import Text.Show
import _SystemArray
/// ## Instances
instance Show {#Char} where
show xs = code inline {
no_op
}
// instance Eq {#Bool} where
// (==) xs ys = inline_equal xs ys
......
......@@ -3,6 +3,8 @@ system module Data.Bool
from Algebra.Order import class Eq, class Ord
from Algebra.Lattice import class MeetSemilattice, class JoinSemilattice, class UpperBounded, class LowerBounded
from Text.Show import class Show
/// # Definition
// :: Bool = True | False
......@@ -10,15 +12,18 @@ from Algebra.Lattice import class MeetSemilattice, class JoinSemilattice, class
/// # Instances
instance Show Bool
instance Eq Bool
instance Ord Bool
// instance Enum Bool
instance MeetSemilattice Bool
instance JoinSemilattice Bool
instance UpperBounded Bool
instance LowerBounded Bool
// instance Enum Bool
/// # Operations
not :: !Bool -> Bool
......
......@@ -3,12 +3,25 @@ implementation module Data.Bool
import Algebra.Order
import Algebra.Lattice
import Text.Show
/// # Definition
// :: Bool = True | False
// BUILTIN
/// # Order
/// # Instances
/// ## Show
instance Show Bool where
show x = code inline {
.d 0 1 b
jsr BtoAC
.o 1 0
}
/// ## Order
instance Eq Bool where
(==) x y = code inline {
......@@ -22,7 +35,7 @@ instance Ord Bool where
// ltB
// }
/// # Algebra
/// ## Lattice
instance MeetSemilattice Bool where
(/\) x y = code {
......
......@@ -4,6 +4,8 @@ from Data.Enum import class Enum
from Algebra.Order import class Eq, class Ord
from Text.Show import class Show
/// # Definition
// :: Char = 'a' | 'b' | 'c' | ... | 'X' | 'Y' | 'Z'
......@@ -14,6 +16,8 @@ ord :: !Char -> Int
/// # Instances
instance Show Char
instance Eq Char
instance Ord Char
......
......@@ -25,6 +25,15 @@ ord c = code inline {
/// # Instances
/// ## Show
instance Show Char where
show x = code inline {
CtoAC
}
/// ## Order
instance Eq Char where
(==) x y = code inline {
eqC
......
......@@ -7,6 +7,8 @@ from Algebra.Group import class Semigroup, class Monoid, class Group
from Algebra.Ring import class Semiring, class Ring, class Domain
from Algebra.Lattice import class MeetSemilattice, class JoinSemilattice, class UpperBounded, class LowerBounded
from Text.Show import class Show
/// # Definition
// :: Int = ... | -2 | -1 | 0 | 1 | 2 | ...
......@@ -14,6 +16,8 @@ from Algebra.Lattice import class MeetSemilattice, class JoinSemilattice, class
/// # Instances
instance Show Int
instance Eq Int
instance Ord Int
......
......@@ -8,8 +8,19 @@ import Algebra.Group
import Algebra.Ring
import Algebra.Lattice
import Text.Show
/// # Instances
/// ## Show
instance Show Int where
show x = code inline {
.d 0 1 i
jsr ItoAC
.o 1 0
}
/// ## Order
instance Eq Int where
......
......@@ -5,6 +5,8 @@ from Algebra.Group import class Semigroup, class Monoid
from Algebra.Ring import class Semiring, class Domain
from Algebra.Lattice import class MeetSemilattice, class JoinSemilattice, class UpperBounded, class LowerBounded
from Text.Show import class Show
/// # Definition
:: Nat (:== Int)
......@@ -14,6 +16,8 @@ int :: !Nat -> Int
/// # Instances
instance Show Nat
instance Eq Nat
instance Ord Nat
......@@ -27,6 +31,8 @@ instance JoinSemilattice Nat
instance UpperBounded Nat
instance LowerBounded Nat
// instance Enum Nat
/// # Special Algebra
(.-) infixl 6 :: !Nat !Nat -> Nat
......@@ -27,6 +27,15 @@ int n = code inline {
/// # Instances
/// ## Show
instance Show Nat where
show x = code inline {
.d 0 1 i
jsr ItoAC
.o 1 0
}
/// ## Order
instance Eq Nat where
......
......@@ -4,6 +4,8 @@ from Algebra.Order import class Eq, class Ord
from Algebra.Group import class Semigroup, class Monoid, class Group
from Algebra.Ring import class Semiring, class Ring, class Field, class Algebraic, class Transcendental
from Text.Show import class Show
/// # Definition
// :: Real = ... | 0 | ...
......@@ -13,6 +15,8 @@ real :: !Int -> Real
/// # Instances
instance Show Real
instance Eq Real
instance Ord Real
......
......@@ -6,6 +6,8 @@ import Algebra.Order
import Algebra.Group
import Algebra.Ring
import Text.Show
/// # Definition
real :: !Int -> Real
......@@ -15,7 +17,16 @@ real x = code inline {
/// # Instances
/// ## Comparisson
/// ## Show
instance Show Real where
show x = undefined /*code inline {
.d 0 2 r
jsr RtoAC
.o 1 0
}*/
/// ## Order
instance Eq Real where
(==) x y = code inline {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment