---!!! Simple array creation
+-- !!! Simple array creation
import Array
---!!! Array creation, (index,value) list with duplicates.
+-- !!! Array creation, (index,value) list with duplicates.
--
-- Haskell library report 1.3 (and earlier) specifies
-- that `array' values created with lists containing dups,
---!!! Array creation, (index,value) list with out of bound index.
+-- !!! Array creation, (index,value) list with out of bound index.
--
-- Haskell library report 1.3 (and earlier) specifies
-- that `array' values created with lists containing out-of-bounds indices,
---!!! Array - accessing undefined element
+-- !!! Array - accessing undefined element
--
-- Sample Haskell implementation in the 1.3 Lib report defines
-- this as being undefined/error.
---!!! Array - recurrences
+-- !!! Array - recurrences
--
-- array does not evaluate the elements.
--
---!!! Array - empty arrays
+-- !!! Array - empty arrays
--
-- print a couple of them to try to expose empty arrays
-- to a GC or two.
---!!! Array - accessing empty arrays
+-- !!! Array - accessing empty arrays
--
-- empty arrays are legal, but indexing them is undefined!
--
---!!! Array - out-of-range (index,value) pairs
+-- !!! Array - out-of-range (index,value) pairs
--
-- supplying a list containing one or more pairs
-- with out-of-range index is undefined.
---!!! Array - derived ops
+-- !!! Array - derived ops
--
-- testing the well-behavedness of
-- derived ops for empty and non-empty arrays
---!!! Array - accumulated arrays
+-- !!! Array - accumulated arrays
--
--
module Main(main) where
---!!! Array - array difference operator
+-- !!! Array - array difference operator
--
--
module Main(main) where
---!!! Array map operations
+-- !!! Array map operations
--
--
module Main(main) where
{-# OPTIONS -fglasgow-exts #-}
---!!! multi-dimensional arrays
+-- !!! multi-dimensional arrays
module Main ( main ) where
import GlaExts
---!!! cc001 -- ccall with standard boxed arguments and results
+-- !!! cc001 -- ccall with standard boxed arguments and results
module ShouldCompile where
---!!! cc002 -- ccall with ambiguous result (should be defaulted to ())
+-- !!! cc002 -- ccall with ambiguous result (should be defaulted to ())
module ShouldCompile where
a :: IO ()
---!!! cc003 -- ccall with unresolved polymorphism (should fail)
---!!! not anymore (as of 0.29, result type will default to ())
+-- !!! cc003 -- ccall with unresolved polymorphism (should fail)
+-- !!! not anymore (as of 0.29, result type will default to ())
module ShouldCompile where
fubar :: IO Int
---!!! cc006 -- ccall with non-standard boxed arguments and results
+-- !!! cc006 -- ccall with non-standard boxed arguments and results
module Test where
---!!! cc002 -- ccall with ambiguous argument
+-- !!! cc002 -- ccall with ambiguous argument
module Test where
f :: IO ()
---!!! cc002 -- ccall with non-standard boxed arguments and results
+-- !!! cc002 -- ccall with non-standard boxed arguments and results
module Test where
---!!! cc004 -- ccall with synonyms, polymorphic type variables and user type variables.
+-- !!! cc004 -- ccall with synonyms, polymorphic type variables and user type variables.
module Test where
-- Since I messed up the handling of polymorphism originally, I'll
---!!! canonical weird example for "deriving"
+-- !!! canonical weird example for "deriving"
module ShouldSucceed where
data X a b
---!!! This is the example given in TcDeriv
+-- !!! This is the example given in TcDeriv
--
module ShouldSucceed where
---!!! simple example of deriving Ord and Eq simultaneously
+-- !!! simple example of deriving Ord and Eq simultaneously
--
module ShouldSucceed where
---!!! simple example of deriving Enum
+-- !!! simple example of deriving Enum
--
module ShouldSucceed where
---!!! simple examples of deriving Ix
+-- !!! simple examples of deriving Ix
--
module ShouldSucceed where
import Ix
---!!! deriving Ord on d. type with a single nullary constructor.
+-- !!! deriving Ord on d. type with a single nullary constructor.
-- (from ghc-2.10 panic - as reported by Sergey Mechveliani <mechvel@botik.ru>)
--
module ShouldSucceed where
---!!! deriving Ix on d. type with nullary constructors
+-- !!! deriving Ix on d. type with nullary constructors
module ShouldSucceed where
import Ix
---!!! deriving Ix on d. type with one constructor
+-- !!! deriving Ix on d. type with one constructor
module ShouldSucceed where
import Ix
---!!! deriving Enum on d. type with nullary constructors
+-- !!! deriving Enum on d. type with nullary constructors
module ShouldSucceed where
data AD = A | B | C | D deriving (Enum)
---!!! deriving Ord without deriving Eq
+-- !!! deriving Ord without deriving Eq
--
module ShouldFail where
---!!! buggy deriving with function type, reported by Sigbjorn Finne
+-- !!! buggy deriving with function type, reported by Sigbjorn Finne
module ShouldFail where
data Foo = Foo (Int -> Int) deriving Eq
--- /dev/null
+-- Originally from Kevin Glynn
+-- Tests existential data types
+
+module Main where
+
+data Coordinate3D = Coord3D {cx, cy, cz::Double}
+ deriving (Eq, Show)
+
+-- We Represent a line by two coordinates which it passes through.
+data Line = MkLine Coordinate3D Coordinate3D
+
+
+class PictureObject pot where
+
+ -- Returns ordered (rel to 0 0 0) of points where the object
+ -- intersects the given line.
+ intersectLineObject :: pot -> Line -> [Coordinate3D]
+
+ getPictureName :: pot -> String
+
+data Sphere =
+ Sphere Coordinate3D -- Centre
+ Double -- Radius
+ Double -- ambient coeff
+ Double -- diffuse coeff
+ Double -- specular coeff
+ Double -- phong specular exponent
+
+intersectLineSphere :: Sphere -> Line -> [Coordinate3D]
+intersectLineSphere sp line = []
+
+instance PictureObject Sphere where
+ intersectLineObject = intersectLineSphere
+ getPictureName _ = "Sphere"
+
+data Cube =
+ Cube Coordinate3D -- Origin corner
+ Coordinate3D -- Opposite corner
+ Double -- ambient coeff
+ Double -- diffuse coeff
+ Double -- specular coeff
+ Double -- phong specular exponent
+ deriving (Eq, Show)
+
+intersectLineCube :: Cube -> Line -> [Coordinate3D]
+intersectLineCube cube line = []
+
+instance PictureObject Cube where
+ intersectLineObject = intersectLineCube
+ getPictureName _ = "Cube"
+
+
+data GenPic = forall pot. (PictureObject pot) => MkGenPic pot
+
+sphere :: Sphere
+sphere = Sphere (Coord3D 1 1 1) 1 1 1 1 1
+
+cube :: Cube
+cube = Cube (Coord3D 1 1 1) (Coord3D 2 2 2) 1 1 1 1
+
+obj_list:: [GenPic]
+obj_list = [MkGenPic sphere, MkGenPic cube]
+
+putName :: PictureObject pot => pot -> IO ()
+putName x = putStr $ getPictureName x
+
+
+main :: IO ()
+main = do { sequence $ map put_it obj_list }
+ where
+ put_it (MkGenPic s) = putStr (getPictureName s)
+