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 ...@@ -24,7 +24,7 @@ Global
Time: False Time: False
Stack: False Stack: False
Output Output
Output: BasicValuesOnly Output: ShowConstructors
Font: Monaco Font: Monaco
FontSize: 9 FontSize: 9
WriteStdErr: False WriteStdErr: False
...@@ -267,6 +267,20 @@ OtherModules ...@@ -267,6 +267,20 @@ OtherModules
ReadableABC: False ReadableABC: False
ReuseUniqueNodes: True ReuseUniqueNodes: True
Fusion: False 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 Module
Name: _SystemArray Name: _SystemArray
Dir: {Application}/lib/StdEnv Dir: {Application}/lib/StdEnv
......
...@@ -19,7 +19,7 @@ import Algebra.Group ...@@ -19,7 +19,7 @@ import Algebra.Group
import Algebra.Ring import Algebra.Ring
import Algebra.Lattice import Algebra.Lattice
// import Text.Show import Text.Show
// import System.Console // import System.Console
// import System.File // import System.File
......
...@@ -14,4 +14,4 @@ c = {1, 2} ...@@ -14,4 +14,4 @@ c = {1, 2}
d :: {#Int} d :: {#Int}
d = {1, 2} d = {1, 2}
Start = a == b Start = ((show a, show 4), (a,c))
...@@ -280,39 +280,13 @@ prim_writeStringFile s f = code inline { ...@@ -280,39 +280,13 @@ prim_writeStringFile s f = code inline {
/// ## Booleans /// ## Booleans
prim_boolToString :: !Bool -> String
prim_boolToString b = code inline {
.d 0 1 b
jsr BtoAC
.o 1 0
}
/// ## Characters /// ## Characters
prim_charToString :: !Char -> String
prim_charToString c = code inline {
CtoAC
}
/// ## Integers /// ## Integers
prim_intToString :: !Int -> String
prim_intToString i = code inline {
.d 0 1 i
jsr ItoAC
.o 1 0
}
/// ## Reals /// ## Reals
prim_realToInt :: !Real -> Int prim_realToInt :: !Real -> Int
prim_realToInt x = code inline { prim_realToInt x = code inline {
RtoI 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 ...@@ -3,6 +3,8 @@ system module Data.Array.Unboxed
from Algebra.Order import class Eq, class Ord from Algebra.Order import class Eq, class Ord
from Algebra.Group import class Semigroup, class Monoid from Algebra.Group import class Semigroup, class Monoid
from Text.Show import class Show
import _SystemArray import _SystemArray
/// # Definition /// # Definition
...@@ -12,6 +14,12 @@ import _SystemArray ...@@ -12,6 +14,12 @@ import _SystemArray
/// # Instances /// # Instances
// instance Show {#Bool}
instance Show {#Char}
// instance Show {#Nat}
// instance Show {#Int}
// instance Show {#Real}
// instance Eq {#Bool} // instance Eq {#Bool}
instance Eq {#Char} instance Eq {#Char}
// instance Eq {#Nat} // instance Eq {#Nat}
......
...@@ -5,10 +5,17 @@ import Data.Function ...@@ -5,10 +5,17 @@ import Data.Function
import Algebra.Order import Algebra.Order
import Algebra.Group import Algebra.Group
import Text.Show
import _SystemArray import _SystemArray
/// ## Instances /// ## Instances
instance Show {#Char} where
show xs = code inline {
no_op
}
// instance Eq {#Bool} where // instance Eq {#Bool} where
// (==) xs ys = inline_equal xs ys // (==) xs ys = inline_equal xs ys
......
...@@ -3,6 +3,8 @@ system module Data.Bool ...@@ -3,6 +3,8 @@ system module Data.Bool
from Algebra.Order import class Eq, class Ord from Algebra.Order import class Eq, class Ord
from Algebra.Lattice import class MeetSemilattice, class JoinSemilattice, class UpperBounded, class LowerBounded from Algebra.Lattice import class MeetSemilattice, class JoinSemilattice, class UpperBounded, class LowerBounded
from Text.Show import class Show
/// # Definition /// # Definition
// :: Bool = True | False // :: Bool = True | False
...@@ -10,15 +12,18 @@ from Algebra.Lattice import class MeetSemilattice, class JoinSemilattice, class ...@@ -10,15 +12,18 @@ from Algebra.Lattice import class MeetSemilattice, class JoinSemilattice, class
/// # Instances /// # Instances
instance Show Bool
instance Eq Bool instance Eq Bool
instance Ord Bool instance Ord Bool
// instance Enum Bool
instance MeetSemilattice Bool instance MeetSemilattice Bool
instance JoinSemilattice Bool instance JoinSemilattice Bool
instance UpperBounded Bool instance UpperBounded Bool
instance LowerBounded Bool instance LowerBounded Bool
// instance Enum Bool
/// # Operations /// # Operations
not :: !Bool -> Bool not :: !Bool -> Bool
......
...@@ -3,12 +3,25 @@ implementation module Data.Bool ...@@ -3,12 +3,25 @@ implementation module Data.Bool
import Algebra.Order import Algebra.Order
import Algebra.Lattice import Algebra.Lattice
import Text.Show
/// # Definition /// # Definition
// :: Bool = True | False // :: Bool = True | False
// BUILTIN // 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 instance Eq Bool where
(==) x y = code inline { (==) x y = code inline {
...@@ -22,7 +35,7 @@ instance Ord Bool where ...@@ -22,7 +35,7 @@ instance Ord Bool where
// ltB // ltB
// } // }
/// # Algebra /// ## Lattice
instance MeetSemilattice Bool where instance MeetSemilattice Bool where
(/\) x y = code { (/\) x y = code {
......
...@@ -4,6 +4,8 @@ from Data.Enum import class Enum ...@@ -4,6 +4,8 @@ from Data.Enum import class Enum
from Algebra.Order import class Eq, class Ord from Algebra.Order import class Eq, class Ord
from Text.Show import class Show
/// # Definition /// # Definition
// :: Char = 'a' | 'b' | 'c' | ... | 'X' | 'Y' | 'Z' // :: Char = 'a' | 'b' | 'c' | ... | 'X' | 'Y' | 'Z'
...@@ -14,6 +16,8 @@ ord :: !Char -> Int ...@@ -14,6 +16,8 @@ ord :: !Char -> Int
/// # Instances /// # Instances
instance Show Char
instance Eq Char instance Eq Char
instance Ord Char instance Ord Char
......
...@@ -25,6 +25,15 @@ ord c = code inline { ...@@ -25,6 +25,15 @@ ord c = code inline {
/// # Instances /// # Instances
/// ## Show
instance Show Char where
show x = code inline {
CtoAC
}
/// ## Order
instance Eq Char where instance Eq Char where
(==) x y = code inline { (==) x y = code inline {
eqC eqC
......
...@@ -7,6 +7,8 @@ from Algebra.Group import class Semigroup, class Monoid, class Group ...@@ -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.Ring import class Semiring, class Ring, class Domain
from Algebra.Lattice import class MeetSemilattice, class JoinSemilattice, class UpperBounded, class LowerBounded from Algebra.Lattice import class MeetSemilattice, class JoinSemilattice, class UpperBounded, class LowerBounded
from Text.Show import class Show
/// # Definition /// # Definition
// :: Int = ... | -2 | -1 | 0 | 1 | 2 | ... // :: Int = ... | -2 | -1 | 0 | 1 | 2 | ...
...@@ -14,6 +16,8 @@ from Algebra.Lattice import class MeetSemilattice, class JoinSemilattice, class ...@@ -14,6 +16,8 @@ from Algebra.Lattice import class MeetSemilattice, class JoinSemilattice, class
/// # Instances /// # Instances
instance Show Int
instance Eq Int instance Eq Int
instance Ord Int instance Ord Int
......
...@@ -8,8 +8,19 @@ import Algebra.Group ...@@ -8,8 +8,19 @@ import Algebra.Group
import Algebra.Ring import Algebra.Ring
import Algebra.Lattice import Algebra.Lattice
import Text.Show
/// # Instances /// # Instances
/// ## Show
instance Show Int where
show x = code inline {
.d 0 1 i
jsr ItoAC
.o 1 0
}
/// ## Order /// ## Order
instance Eq Int where instance Eq Int where
......
...@@ -5,6 +5,8 @@ from Algebra.Group import class Semigroup, class Monoid ...@@ -5,6 +5,8 @@ from Algebra.Group import class Semigroup, class Monoid
from Algebra.Ring import class Semiring, class Domain from Algebra.Ring import class Semiring, class Domain
from Algebra.Lattice import class MeetSemilattice, class JoinSemilattice, class UpperBounded, class LowerBounded from Algebra.Lattice import class MeetSemilattice, class JoinSemilattice, class UpperBounded, class LowerBounded
from Text.Show import class Show
/// # Definition /// # Definition
:: Nat (:== Int) :: Nat (:== Int)
...@@ -14,6 +16,8 @@ int :: !Nat -> Int ...@@ -14,6 +16,8 @@ int :: !Nat -> Int
/// # Instances /// # Instances
instance Show Nat
instance Eq Nat instance Eq Nat
instance Ord Nat instance Ord Nat
...@@ -27,6 +31,8 @@ instance JoinSemilattice Nat ...@@ -27,6 +31,8 @@ instance JoinSemilattice Nat
instance UpperBounded Nat instance UpperBounded Nat
instance LowerBounded Nat instance LowerBounded Nat
// instance Enum Nat
/// # Special Algebra /// # Special Algebra
(.-) infixl 6 :: !Nat !Nat -> Nat (.-) infixl 6 :: !Nat !Nat -> Nat
...@@ -27,6 +27,15 @@ int n = code inline { ...@@ -27,6 +27,15 @@ int n = code inline {
/// # Instances /// # Instances
/// ## Show
instance Show Nat where
show x = code inline {
.d 0 1 i
jsr ItoAC
.o 1 0
}
/// ## Order /// ## Order
instance Eq Nat where instance Eq Nat where
......
...@@ -4,6 +4,8 @@ from Algebra.Order import class Eq, class Ord ...@@ -4,6 +4,8 @@ from Algebra.Order import class Eq, class Ord
from Algebra.Group import class Semigroup, class Monoid, class Group 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 Algebra.Ring import class Semiring, class Ring, class Field, class Algebraic, class Transcendental
from Text.Show import class Show
/// # Definition /// # Definition
// :: Real = ... | 0 | ... // :: Real = ... | 0 | ...
...@@ -13,6 +15,8 @@ real :: !Int -> Real ...@@ -13,6 +15,8 @@ real :: !Int -> Real
/// # Instances /// # Instances
instance Show Real
instance Eq Real instance Eq Real
instance Ord Real instance Ord Real
......
...@@ -6,6 +6,8 @@ import Algebra.Order ...@@ -6,6 +6,8 @@ import Algebra.Order
import Algebra.Group import Algebra.Group
import Algebra.Ring import Algebra.Ring
import Text.Show
/// # Definition /// # Definition
real :: !Int -> Real real :: !Int -> Real
...@@ -15,7 +17,16 @@ real x = code inline { ...@@ -15,7 +17,16 @@ real x = code inline {
/// # Instances /// # 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 instance Eq Real where
(==) x y = code inline { (==) 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