shithub: MicroHs

Download patch

ref: b9915c0c25d26b0a714cc9075d516e22f92b6bcc
parent: 121e692078d17da589d60cc9051c49704fb9c833
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Mon Sep 18 06:05:11 EDT 2023

Define some primitive types in Primitives.hs

--- a/comb/mhs.comb
+++ b/comb/mhs.comb
@@ -1,3 +1,3 @@
 v3.3
-824
-(($A :0 ((_626 _579) (($B ((($S' ($C ((($C' ($S' _626)) (($B ($C _2)) _564)) (($B ($B (_626 _654))) ((($C' ($C' $C)) ((($C' ($S' ($C' $C))) ((($C' ($C' ($C' $C))) ((($C' ($C' ($C' ($C' $S')))) (($B ($B ($B ($B $C)))) ((($C' ($C' ($C' $B))) (($B ($B ($B ($C' $S)))) ((($C' ($C' ($C' ($C' $C)))) ((($C' ($C' ($C' ($C' ($C' $S'))))) (($B ($B ($B ($B ($B $C))))) ((($C' ($C' ($C' ($C' ($C' $C))))) ((($C' ($C' ($C' $B))) (($B ($B ($B ($C' ($C' $S'))))) ((($C' ($C' ($C' ($C' ($C' $C'))))) ((($C' ($C' ($C' ($S' ($C' $C'))))) (($B ($B ($B ($B $B')))) ((($S' $B) ($B' ($B' (($B ($S' $B)) (($B ($B _627)) ((($C' $B) (($B _721) (($B _644) ((($C' _759) _8) 0)))) (($B (_721 _647)) (($B (_660 "top level defns: ")) _608)))))))) ((($S' $B) ($B' (($B ($C' $B)) (($B $B') (($B ($B _627)) ((($C' $B) (($B _721) (($B _644) ((($C' _759) _8) 1)))) (_643 ($T (($B ($B (_721 _647))) ((($C' $B) (($B _660) ((($C' _660) _569) " = "))) _396)))))))))) ((($C' $B) ((($S' $C') (($B $C') (($B $C') _9))) ((($S' $B) (($B ($C' ($C' _627))) ((($C' $B) ($B' (($B _721) (($B _649) _11)))) (($B _660) ((($C' _660) (($B (_660 _1)) _608)) (($O 10) $K)))))) (($B ($B (_626 _654))) ((($C' $B) ($B' (($B _721) (($B _644) ((($C' _759) _8) 0))))) (($B ($B (_721 _647))) ((($C' ($C' _660)) (($B ($B (_660 "final pass            "))) (($B ($B (_621 6))) (($B ($B _608)) _753)))) "ms"))))))) _3))))) (($B (($C' $C) (($B ($C _665)) _396))) (($C _678) (_695 0))))) (($B ($C $B)) (($B ($B ($C $B))) (($B ($B $BK)) ((($C' ($C' ($C' ($C' _660)))) (($B ($C' ($C' _660))) ((($C' ($C' ($C' _660))) (($B (($C' $B) (($B _660) ((($C' _660) (($B (_660 "(($A :")) _608)) (($O 32) $K))))) ($B _396))) ") "))) (($O 41) $K)))))))) $T)) (($B $Y) ((($C' ($C' $S)) ((($C' ($C' $S)) ((($C' $B) $P) ((($S' ($C' $B)) ($B _372)) $I))) ($BK $K))) $K))))) (($B (($S' _721) (($B _718) (($B (_721 _768)) (($B (_660 "main: findIdent: ")) _569))))) (($C' _598) _566)))) _605))) (($B ($B _602)) ((($C' $B) (($B _662) (($B $T) (($B ($C $B)) (($B ($B $BK)) ((($C' ($C' ($C' $O))) ($B (($C' $P) _566))) $K)))))) (($C _678) (_695 0))))))) ($T $A))) ($T $K))) $I)) (($B (_721 _371)) (($B (_721 _564)) (($B (_660 (($O 95) $K))) _608)))))))) (($S (($S ((($S' _7) (($B _677) (_664 (_619 "-v")))) ((_694 _619) "-r"))) (($B (_658 (($O 46) $K))) (($B _720) (_663 ((_682 _744) "-i")))))) (($B (_721 _689)) ((($C' _660) (($B _720) (_663 ((_682 _744) "-o")))) (($O "out.comb") $K))))) (($B (($S (($C ((($C' _755) _677) 1)) (_768 "Usage: mhs [-v] [-r] [-iPATH] [-oFILE] ModuleName"))) _689)) (_664 ((_722 _764) ((_722 (_619 (($O 45) $K))) (_675 1))))))) (_685 ((_722 _764) (_619 "--")))))) (($A :1 "v3.3\10&") (($A :2 ((($S' ($S' _626)) _16) (($B ($B ($B (_626 _654)))) ((($C' ($C' $B)) (($B ($B ($C' (($S' _627) (($B (_721 _645)) (($B (_721 (_676 1000000))) _192)))))) (($B ($B ($B ($B (_626 _654))))) ((($C' $B) (($B ($C' $B)) (($B ($B ($C' _627))) ((($C' $B) ($B' (($B _721) (($B _644) ((($C' _759) _8) 0))))) (($B ($B (_721 _647))) ((($C' ($C' _660)) (($B ($B (_660 "combinator conversion "))) (($B ($B (_621 6))) (($B ($B _608)) _753)))) "ms")))))) (($B ($B _628)) (($B $P) (($C _572) (_564 "main")))))))) (_662 ($T ((($C' ($C' $O)) ((($C' $B) $P) _399)) $K))))))) (($A :3 ($T (($C ((($C' $C') (($B ($S' ($B (_626 _579)))) (($B ($B ($B (($C' _580) ((($C' _748) (($B _677) (_685 ((_722 _764) (_619 "--"))))) 1))))) (($B ($B ($B (_721 _6)))) ($C $C))))) (($B ($B $Y)) (($B ($B ($B _555))) (($C' ($C' _662)) (($B ($B $T)) ((($C' ($C' ($C' ($C' $O)))) (($B ($B (($C' $B) $P))) ($B _4))) $K))))))) (($B (($S' _721) (($B _718) (($B (_721 _768)) (($B (_660 "not found ")) _569))))) ($C _556))))) (($A :4 ((($C' $C) ((($S' $C) ((($C' ($C' $S')) (($S $P) ((($S' ($C' $B)) (($B ($B _6)) _4)) _4))) ($BK $K))) ((($C' ($S' $C)) ((($C' ($C' $C)) (($B (($C' $C) (($B ($P _6)) $K))) ((($C' $B) _4) _398))) (($B (_721 (_718 (_768 "primlookup")))) (($C (_700 _619)) _5)))) $K))) (_768 "trans: impossible"))) (($A :5 (($O (($P (($O 66) $K)) $B)) (($O (($P (($O 79) $K)) $O)) (($O (($P (($O 75) $K)) $K)) (($O (($P "C'") $C')) (($O (($P (($O 67) $K)) $C)) (($O (($P (($O 65) $K)) $A)) (($O (($P "
\ No newline at end of file
+821
+(($A :0 ((_623 _576) (($B ((($S' ($C ((($C' ($S' _623)) (($B ($C _2)) _561)) (($B ($B (_623 _651))) ((($C' ($C' $C)) ((($C' ($S' ($C' $C))) ((($C' ($C' ($C' $C))) ((($C' ($C' ($C' ($C' $S')))) (($B ($B ($B ($B $C)))) ((($C' ($C' ($C' $B))) (($B ($B ($B ($C' $S)))) ((($C' ($C' ($C' ($C' $C)))) ((($C' ($C' ($C' ($C' ($C' $S'))))) (($B ($B ($B ($B ($B $C))))) ((($C' ($C' ($C' ($C' ($C' $C))))) ((($C' ($C' ($C' $B))) (($B ($B ($B ($C' ($C' $S'))))) ((($C' ($C' ($C' ($C' ($C' $C'))))) ((($C' ($C' ($C' ($S' ($C' $C'))))) (($B ($B ($B ($B $B')))) ((($S' $B) ($B' ($B' (($B ($S' $B)) (($B ($B _624)) ((($C' $B) (($B _718) (($B _641) ((($C' _756) _8) 0)))) (($B (_718 _644)) (($B (_657 "top level defns: ")) _605)))))))) ((($S' $B) ($B' (($B ($C' $B)) (($B $B') (($B ($B _624)) ((($C' $B) (($B _718) (($B _641) ((($C' _756) _8) 1)))) (_640 ($T (($B ($B (_718 _644))) ((($C' $B) (($B _657) ((($C' _657) _566) " = "))) _393)))))))))) ((($C' $B) ((($S' $C') (($B $C') (($B $C') _9))) ((($S' $B) (($B ($C' ($C' _624))) ((($C' $B) ($B' (($B _718) (($B _646) _11)))) (($B _657) ((($C' _657) (($B (_657 _1)) _605)) (($O 10) $K)))))) (($B ($B (_623 _651))) ((($C' $B) ($B' (($B _718) (($B _641) ((($C' _756) _8) 0))))) (($B ($B (_718 _644))) ((($C' ($C' _657)) (($B ($B (_657 "final pass            "))) (($B ($B (_618 6))) (($B ($B _605)) _750)))) "ms"))))))) _3))))) (($B (($C' $C) (($B ($C _662)) _393))) (($C _675) (_692 0))))) (($B ($C $B)) (($B ($B ($C $B))) (($B ($B $BK)) ((($C' ($C' ($C' ($C' _657)))) (($B ($C' ($C' _657))) ((($C' ($C' ($C' _657))) (($B (($C' $B) (($B _657) ((($C' _657) (($B (_657 "(($A :")) _605)) (($O 32) $K))))) ($B _393))) ") "))) (($O 41) $K)))))))) $T)) (($B $Y) ((($C' ($C' $S)) ((($C' ($C' $S)) ((($C' $B) $P) ((($S' ($C' $B)) ($B _369)) $I))) ($BK $K))) $K))))) (($B (($S' _718) (($B _715) (($B (_718 _765)) (($B (_657 "main: findIdent: ")) _566))))) (($C' _595) _563)))) _602))) (($B ($B _599)) ((($C' $B) (($B _659) (($B $T) (($B ($C $B)) (($B ($B $BK)) ((($C' ($C' ($C' $O))) ($B (($C' $P) _563))) $K)))))) (($C _675) (_692 0))))))) ($T $A))) ($T $K))) $I)) (($B (_718 _368)) (($B (_718 _561)) (($B (_657 (($O 95) $K))) _605)))))))) (($S (($S ((($S' _7) (($B _674) (_661 (_616 "-v")))) ((_691 _616) "-r"))) (($B (_655 (($O 46) $K))) (($B _717) (_660 ((_679 _741) "-i")))))) (($B (_718 _686)) ((($C' _657) (($B _717) (_660 ((_679 _741) "-o")))) (($O "out.comb") $K))))) (($B (($S (($C ((($C' _752) _674) 1)) (_765 "Usage: mhs [-v] [-r] [-iPATH] [-oFILE] ModuleName"))) _686)) (_661 ((_719 _761) ((_719 (_616 (($O 45) $K))) (_672 1))))))) (_682 ((_719 _761) (_616 "--")))))) (($A :1 "v3.3\10&") (($A :2 ((($S' ($S' _623)) _16) (($B ($B ($B (_623 _651)))) ((($C' ($C' $B)) (($B ($B ($C' (($S' _624) (($B (_718 _642)) (($B (_718 (_673 1000000))) _192)))))) (($B ($B ($B ($B (_623 _651))))) ((($C' $B) (($B ($C' $B)) (($B ($B ($C' _624))) ((($C' $B) ($B' (($B _718) (($B _641) ((($C' _756) _8) 0))))) (($B ($B (_718 _644))) ((($C' ($C' _657)) (($B ($B (_657 "combinator conversion "))) (($B ($B (_618 6))) (($B ($B _605)) _750)))) "ms")))))) (($B ($B _625)) (($B $P) (($C _569) (_561 "main")))))))) (_659 ($T ((($C' ($C' $O)) ((($C' $B) $P) _396)) $K))))))) (($A :3 ($T (($C ((($C' $C') (($B ($S' ($B (_623 _576)))) (($B ($B ($B (($C' _577) ((($C' _745) (($B _674) (_682 ((_719 _761) (_616 "--"))))) 1))))) (($B ($B ($B (_718 _6)))) ($C $C))))) (($B ($B $Y)) (($B ($B ($B _552))) (($C' ($C' _659)) (($B ($B $T)) ((($C' ($C' ($C' ($C' $O)))) (($B ($B (($C' $B) $P))) ($B _4))) $K))))))) (($B (($S' _718) (($B _715) (($B (_718 _765)) (($B (_657 "not found ")) _566))))) ($C _553))))) (($A :4 ((($C' $C) ((($S' $C) ((($C' ($C' $S')) (($S $P) ((($S' ($C' $B)) (($B ($B _6)) _4)) _4))) ($BK $K))) ((($C' ($S' $C)) ((($C' ($C' $C)) (($B (($C' $C) (($B ($P _6)) $K))) ((($C' $B) _4) _395))) (($B (_718 (_715 (_765 "primlookup")))) (($C (_697 _616)) _5)))) $K))) (_765 "trans: impossible"))) (($A :5 (($O (($P (($O 66) $K)) $B)) (($O (($P (($O 79) $K)) $O)) (($O (($P (($O 75) $K)) $K)) (($O (($P "C'") $C')) (($O (($P (($O 67) $K)) $C)) (($O (($P (($O 65) $K)) $A)) (($O (($P "
\ No newline at end of file
--- a/ghc/Primitives.hs
+++ b/ghc/Primitives.hs
@@ -1,10 +1,11 @@
 module Primitives(
   module Primitives,
+  Any,
   Char,
+  Handle,
   Int,
-  Word,
   IO,
-  Handle,
+  Word,
   ) where
 import Control.Exception(try)
 import Data.Time
@@ -14,6 +15,7 @@
 import System.IO.Unsafe
 import System.Environment
 import Unsafe.Coerce
+import GHC.Types(Any)
 
 primIntAdd :: Int -> Int -> Int
 primIntAdd = (+)
--- a/lib/Data/Char.hs
+++ b/lib/Data/Char.hs
@@ -1,43 +1,41 @@
 -- Copyright 2023 Lennart Augustsson
 -- See LICENSE file for full license.
-module Data.Char(module Data.Char) where
-import qualified Primitives as P
+module Data.Char(module Data.Char, Char) where
+import Primitives
 import Data.Bool
 import Data.Int
 
---Ytype Char = P.Char
---Ytype Int  = P.Int
 type String = [Char]
 
 chr :: Int -> Char
-chr = P.primChr
+chr = primChr
 
 ord :: Char -> Int
-ord = P.primOrd
+ord = primOrd
 
 isLower :: Char -> Bool
-isLower c = (P.primCharLE 'a' c) && (P.primCharLE c 'z')
+isLower c = (primCharLE 'a' c) && (primCharLE c 'z')
 
 isUpper :: Char -> Bool
-isUpper c = (P.primCharLE 'A' c) && (P.primCharLE c 'Z')
+isUpper c = (primCharLE 'A' c) && (primCharLE c 'Z')
 
 isAlpha :: Char -> Bool
 isAlpha c = isLower c || isUpper c
 
 isDigit :: Char -> Bool
-isDigit c = (P.primCharLE '0' c) && (P.primCharLE c '9')
+isDigit c = (primCharLE '0' c) && (primCharLE c '9')
 
 isPrint :: Char -> Bool
-isPrint c = P.primCharLE ' ' c && P.primCharLE c '~'
+isPrint c = primCharLE ' ' c && primCharLE c '~'
 
 eqChar :: Char -> Char -> Bool
-eqChar = P.primCharEQ
+eqChar = primCharEQ
 
 neChar :: Char -> Char -> Bool
-neChar = P.primCharNE
+neChar = primCharNE
 
 leChar :: Char -> Char -> Bool
-leChar = P.primCharLE
+leChar = primCharLE
 
 ltChar :: Char -> Char -> Bool
-ltChar = P.primCharLT
+ltChar = primCharLT
--- a/lib/Data/Int.hs
+++ b/lib/Data/Int.hs
@@ -1,6 +1,6 @@
 -- Copyright 2023 Lennart Augustsson
 -- See LICENSE file for full license.
-module Data.Int(module Data.Int) where
+module Data.Int(module Data.Int, Int) where
 import Primitives
 import Data.Bool_Type
 
--- a/lib/Data/List.hs
+++ b/lib/Data/List.hs
@@ -1,6 +1,7 @@
 -- Copyright 2023 Lennart Augustsson
 -- See LICENSE file for full license.
 module Data.List(module Data.List) where
+import Primitives as P
 import Control.Error
 import Data.Bool
 import Data.Function
@@ -9,7 +10,6 @@
 import Data.Tuple
 
 --Yimport Data.Char
---type Int = P.Int
 
 --X{-
 --Y{-
@@ -66,10 +66,10 @@
 foldl1 _ [] = error "foldl1"
 foldl1 f (x : xs) = foldl f x xs
 
-sum :: [Int] -> Int
+sum :: [P.Int] -> P.Int
 sum = foldr (+) 0
 
-product :: [Int] -> Int
+product :: [P.Int] -> P.Int
 product = foldr (*) 1
 
 and :: [Bool] -> Bool
@@ -84,7 +84,7 @@
 all :: forall a . (a -> Bool) -> [a] -> Bool
 all p = and . map p
 
-take :: forall a . Int -> [a] -> [a]
+take :: forall a . P.Int -> [a] -> [a]
 take n arg =
   if n <= 0 then
     []
@@ -93,7 +93,7 @@
       [] -> []
       x : xs -> x : take (n - 1) xs
 
-drop :: forall a . Int -> [a] -> [a]
+drop :: forall a . P.Int -> [a] -> [a]
 drop n arg =
   if n <= 0 then
     arg
@@ -102,7 +102,7 @@
       [] -> []
       _ : xs -> drop (n - 1) xs
 
-length :: forall a . [a] -> Int
+length :: forall a . [a] -> P.Int
 length [] = 0
 length (_:xs) = 1 + length xs
 
@@ -135,7 +135,7 @@
 stripPrefixBy eq (c:cs) (d:ds) | eq c d = stripPrefixBy eq cs ds
                                | otherwise = Nothing
 
-splitAt :: forall a . Int -> [a] -> ([a], [a])
+splitAt :: forall a . P.Int -> [a] -> ([a], [a])
 splitAt n xs = (take n xs, drop n xs)
 
 reverse :: forall a . [a] -> [a]
@@ -197,18 +197,18 @@
 elemBy :: forall a . (a -> a -> Bool) -> a -> [a] -> Bool
 elemBy eq a = any (eq a)
 
-enumFrom :: Int -> [Int]
+enumFrom :: P.Int -> [P.Int]
 enumFrom n = n : enumFrom (n+1)
 
-enumFromThen :: Int -> Int -> [Int]
+enumFromThen :: P.Int -> P.Int -> [P.Int]
 enumFromThen n m = from n
   where d = m - n
         from i = i : from (i+d)
 
-enumFromTo :: Int -> Int -> [Int]
+enumFromTo :: P.Int -> P.Int -> [P.Int]
 enumFromTo l h = takeWhile (<= h) (enumFrom l)
 
-enumFromThenTo :: Int -> Int -> Int -> [Int]
+enumFromThenTo :: P.Int -> P.Int -> P.Int -> [P.Int]
 enumFromThenTo l m h =
   if m - l > 0 then
     takeWhile (<= h) (enumFromThen l m)
@@ -240,7 +240,7 @@
 nubBy _ [] = []
 nubBy eq (x:xs) = x : nubBy eq (filter (\ y -> not (eq x y)) xs)
 
-replicate :: forall a . Int -> a -> [a]
+replicate :: forall a . P.Int -> a -> [a]
 replicate n x = take n (repeat x)
 
 repeat :: forall a . a -> [a]
@@ -256,7 +256,7 @@
 deleteAllsBy eq = foldl (flip (deleteAllBy eq))
 
 infixl 9 !!
-(!!) :: forall a . [a] -> Int -> a
+(!!) :: forall a . [a] -> P.Int -> a
 (!!) axs i =
   if i < 0 then
     error "!!: <0"
--- a/lib/Data/Word.hs
+++ b/lib/Data/Word.hs
@@ -1,6 +1,6 @@
 -- Copyright 2023 Lennart Augustsson
 -- See LICENSE file for full license.
-module Data.Word(module Data.Word) where
+module Data.Word(module Data.Word, Word) where
 import Primitives
 import Data.Bool_Type
 import qualified Data.Char as C
@@ -8,21 +8,19 @@
 import Data.List
 import Text.String
 
---type Word = Primitives.Word
-
 infixl 6 +,-
 infixl 7 *,`quot`,`rem`
 
 -- Arithmetic
-(+) :: {-Data.Word.-}Word -> {-Data.Word.-}Word -> {-Data.Word.-}Word
+(+) :: Word -> Word -> Word
 (+)  = primWordAdd
-(-) :: {-Data.Word.-}Word -> {-Data.Word.-}Word -> {-Data.Word.-}Word
+(-) :: Word -> Word -> Word
 (-)  = primWordSub
-(*) :: {-Data.Word.-}Word -> {-Data.Word.-}Word -> {-Data.Word.-}Word
+(*) :: Word -> Word -> Word
 (*)  = primWordMul
-quot :: {-Data.Word.-}Word -> {-Data.Word.-}Word -> {-Data.Word.-}Word
+quot :: Word -> Word -> Word
 quot = primWordQuot
-rem :: {-Data.Word.-}Word -> {-Data.Word.-}Word -> {-Data.Word.-}Word
+rem :: Word -> Word -> Word
 rem  = primWordRem
 
 --------------------------------
@@ -30,21 +28,21 @@
 infix 4 ==,/=,<,<=,>,>=
 
 -- Comparison
-(==) :: {-Data.Word.-}Word -> {-Data.Word.-}Word -> Bool
+(==) :: Word -> Word -> Bool
 (==) = primWordEQ
-(/=) :: {-Data.Word.-}Word -> {-Data.Word.-}Word -> Bool
+(/=) :: Word -> Word -> Bool
 (/=) = primWordNE
 
-(<)  :: {-Data.Word.-}Word -> {-Data.Word.-}Word -> Bool
+(<)  :: Word -> Word -> Bool
 (<)  = primWordLT
-(<=) :: {-Data.Word.-}Word -> {-Data.Word.-}Word -> Bool
+(<=) :: Word -> Word -> Bool
 (<=) = primWordLE
-(>)  :: {-Data.Word.-}Word -> {-Data.Word.-}Word -> Bool
+(>)  :: Word -> Word -> Bool
 (>)  = primWordGT
-(>=) :: {-Data.Word.-}Word -> {-Data.Word.-}Word -> Bool
+(>=) :: Word -> Word -> Bool
 (>=) = primWordGE
 
-eqWord :: {-Data.Word.-}Word -> {-Data.Word.-}Word -> Bool
+eqWord :: Word -> Word -> Bool
 eqWord = (==)
 
 intToWord :: Int -> Word
--- a/lib/Primitives.hs
+++ b/lib/Primitives.hs
@@ -9,6 +9,13 @@
 --Y-}
 --X-}
 
+data Any
+data Char
+data Handle
+data Int
+data IO a
+data Word
+
 primIntAdd :: Int -> Int -> Int
 primIntAdd  = primitive "+"
 primIntSub :: Int -> Int -> Int
--- a/lib/System/IO.hs
+++ b/lib/System/IO.hs
@@ -1,7 +1,7 @@
 -- Copyright 2023 Lennart Augustsson
 -- See LICENSE file for full license.
-module System.IO(module System.IO) where
-import qualified Primitives as P
+module System.IO(module System.IO, Handle, IO) where
+import Primitives
 import Control.Error
 import Data.Bool
 import Data.Char
@@ -10,9 +10,6 @@
 import Data.Maybe
 import Data.Tuple
 
---Ytype IO = P.IO
---Ytype Handle = P.Handle
-
 type FilePath = String
 
 data IOMode = ReadMode | WriteMode | AppendMode | ReadWriteMode
@@ -19,31 +16,31 @@
 
 infixl 1 >>=
 (>>=)       :: forall a b . IO a -> (a -> IO b) -> IO b
-(>>=)        = P.primBind
+(>>=)        = primBind
 
 infixl 1 >>
 (>>)        :: forall a b . IO a -> IO b -> IO b
-(>>)         = P.primThen
+(>>)         = primThen
 
 return      :: forall a . a -> IO a
-return       = P.primReturn
+return       = primReturn
 
 hSerialize   :: forall a . Handle -> a -> IO ()
-hSerialize   = P.primHSerialize
+hSerialize   = primHSerialize
 hDeserialize :: forall a . Handle -> IO a
-hDeserialize = P.primHDeserialize
+hDeserialize = primHDeserialize
 hClose       :: Handle -> IO ()
-hClose       = P.primHClose
+hClose       = primHClose
 stdin        :: Handle
-stdin        = P.primStdin
+stdin        = primStdin
 stdout       :: Handle
-stdout       = P.primStdout
+stdout       = primStdout
 stderr       :: Handle
-stderr       = P.primStderr
+stderr       = primStderr
 
 hGetChar :: Handle -> IO Char
 hGetChar h = do
-  c <- P.primHGetChar h
+  c <- primHGetChar h
   if c == negate 1 then
     error "hGetChar: EOF"
    else
@@ -50,7 +47,7 @@
     return (chr c)
 
 hPutChar :: Handle -> Char -> IO ()
-hPutChar h c = P.primHPutChar h (ord c)
+hPutChar h c = primHPutChar h (ord c)
 
 openFileM :: FilePath -> IOMode -> IO (Maybe Handle)
 openFileM p m = do
@@ -60,8 +57,8 @@
           WriteMode -> 1
           AppendMode -> 2
           ReadWriteMode -> 3
-  hdl <- P.primOpenFile p n
-  if P.primIsNullHandle hdl then
+  hdl <- primOpenFile p n
+  if primIsNullHandle hdl then
     return Nothing
    else
     return (Just hdl)
@@ -80,7 +77,7 @@
 getChar = hGetChar stdin
 
 print :: forall a . a -> IO ()
-print = P.primHPrint stdout
+print = primHPrint stdout
 
 mapM :: forall a b . (a -> IO b) -> [a] -> IO [b]
 mapM f =
@@ -133,7 +130,7 @@
 -- Lazy hGetContents
 hGetContents :: Handle -> IO String
 hGetContents h = do
-  c <- P.primHGetChar h
+  c <- primHGetChar h
   if c == negate 1 then do
     hClose h   -- EOF, so close the handle
     return ""
@@ -155,10 +152,10 @@
   return a
 
 getTimeMilli :: IO Int
-getTimeMilli = P.primGetTimeMilli
+getTimeMilli = primGetTimeMilli
 
 unsafeInterleaveIO :: forall a . IO a -> IO a
-unsafeInterleaveIO ioa = return (P.primPerformIO ioa)
+unsafeInterleaveIO ioa = return (primPerformIO ioa)
 
 seq :: forall a b . a -> b -> b
-seq = P.primSeq
+seq = primSeq
--- a/lib/Unsafe/Coerce.hs
+++ b/lib/Unsafe/Coerce.hs
@@ -1,4 +1,4 @@
-module Unsafe.Coerce(module Unsafe.Coerce) where
+module Unsafe.Coerce(module Unsafe.Coerce, Any) where
 import Primitives
 
 unsafeCoerce :: forall a b . a -> b
--- a/src/MicroHs/Parse.hs
+++ b/src/MicroHs/Parse.hs
@@ -112,7 +112,8 @@
 
 keywords :: [String]
 keywords = ["case", "data", "do", "else", "forall", "foreign", "if", "import",
-  "in", "let", "module", "newtype", "of", "primitive", "then", "type", "where"]
+  "in", "infix", "infixl", "infixr",
+  "let", "module", "newtype", "of", "primitive", "then", "type", "where"]
 
 pSpec :: Char -> P ()
 pSpec c = () <$ satisfy [c] is
@@ -228,9 +229,10 @@
 
 pDef :: P EDef
 pDef =
-      Data        <$> (pKeyword "data"    *> pLHS <* pSymbol "=") <*> esepBy1 (pair <$> pUIdentSym <*> many pAType) (pSymbol "|")
-  <|> Newtype     <$> (pKeyword "newtype" *> pLHS <* pSymbol "=") <*> pUIdent <*> pAType
-  <|> Type        <$> (pKeyword "type"    *> pLHS <* pSymbol "=") <*> pType
+      Data        <$> (pKeyword "data"    *> pLHS) <*> ((pSymbol "=" *> esepBy1 (pair <$> pUIdentSym <*> many pAType) (pSymbol "|"))
+                                                        <|< P.pure [])
+  <|> Newtype     <$> (pKeyword "newtype" *> pLHS) <*> (pSymbol "=" *> pUIdent) <*> pAType
+  <|> Type        <$> (pKeyword "type"    *> pLHS) <*> (pSymbol "=" *> pType)
   <|> uncurry Fcn <$> pEqns
   <|> Sign        <$> (pLIdentSym <* pSymbol "::") <*> pTypeScheme
   <|> Import      <$> (pKeyword "import" *> pImportSpec)
--- a/src/MicroHs/TypeCheck.hs
+++ b/src/MicroHs/TypeCheck.hs
@@ -25,12 +25,6 @@
 data ValueExport = ValueExport Ident Entry
   --Xderiving (Show)
 
-data TypeInfo
-  = TAbs EKind
-  | TConc EKind [(Ident, ETypeScheme)]   -- constructor name, arity, and type
-  | TSyn EKind ETypeScheme
-  --Xderiving (Show, Eq)
-
 type FixDef = (Ident, Fixity)
 type SynDef = (Ident, ETypeScheme)
 
@@ -294,13 +288,8 @@
         i = tupleConstr n
       in  (i, [entry (unIdent i) $ ETypeScheme [] $ foldr kArrow kType (replicate n kType)])
   in  
-      [(mkIdent "IO",     [entry "Primitives.IO"       kTypeTypeS]),
+      [
        (mkIdent "->",     [entry "Primitives.->"       kTypeTypeTypeS]),
-       (mkIdent "Int",    [entry "Primitives.Int"      kTypeS]),
-       (mkIdent "Word",   [entry "Primitives.Word"     kTypeS]),
-       (mkIdent "Char",   [entry "Primitives.Char"     kTypeS]),
-       (mkIdent "Handle", [entry "Primitives.Handle"   kTypeS]),
-       (mkIdent "Any",    [entry "Primitives.Any"      kTypeS]),
        (mkIdent "String", [entry "Data.Char.String"    kTypeS]),
        (mkIdent "[]",     [entry "Data.List.[]"        kTypeTypeS]),
        (mkIdent "()",     [entry "Data.Tuple.()"       kTypeS]),
--- a/src/PrimTable.hs
+++ b/src/PrimTable.hs
@@ -1,4 +1,4 @@
-module PrimTable(module PrimTable, Any) where
+module PrimTable(module PrimTable) where
 import Data.Char
 import Data.Maybe
 import System.IO
--- a/tests/Word.hs
+++ b/tests/Word.hs
@@ -9,6 +9,5 @@
   putStrLn $ W.showWord twoTo32M1
   putStrLn $ W.showWord $ (W.*) twoTo32M1 twoTo32M1
 
-twoTo32M1 :: Word
+twoTo32M1 :: W.Word
 twoTo32M1 = W.intToWord 4294967295
-
--