@@ -9,7 +9,6 @@ import public Prelude.Bool
99import public Prelude.Classes
1010import public Prelude.Cast
1111import public Prelude.Nat
12−import public Prelude.Fin
1312import public Prelude.List
1413import public Prelude.Maybe
1514import public Prelude.Monad
@@ -17,14 +16,13 @@ import public Prelude.Applicative
1716import public Prelude.Foldable
1817import public Prelude.Functor
1918import public Prelude.Either
20−import public Prelude.Vect
2119import public Prelude.Strings
2220import public Prelude.Chars
2321import public Prelude.Traversable
2422import public Prelude.Bits
25−import public Prelude.Stream
2623import public Prelude.Uninhabited
2724import public Prelude.Pairs
25+import public Prelude.Stream
2826
2927import public Decidable.Equality
3028import public Language.Reflection
@@ -47,11 +45,6 @@ instance Show Integer where
4745instance Show Float where
4846 show = prim__floatToStr
4947
50−asciiTab : Vect 32 String
51−asciiTab = ["NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
52− "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI",
53− "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB",
54− "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US"]
5548
5649firstCharIs : (Char -> Bool) -> String -> Bool
5750firstCharIs p s with (strM s)
@@ -72,11 +65,21 @@ showLitChar '\v' = ("\\v" ++)
7265showLitChar '\SO' = protectEsc (== 'H') "\\SO"
7366showLitChar '\DEL' = ("\\DEL" ++)
7467showLitChar '\\' = ("\\\\" ++)
75−showLitChar c = case (integerToFin (cast (cast {to=Int} c)) 32) of
76− Just k => strCons '\\' . ((index k asciiTab) ++)
68+showLitChar c = case getAt (cast (cast {to=Int} c)) asciiTab of
69+ Just k => strCons '\\' . (k ++)
7770 Nothing => if (c > '\DEL')
7871 then strCons '\\' . protectEsc isDigit (show (cast {to=Int} c))
7972 else strCons c
73+ where asciiTab : List String
74+ asciiTab = ["NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
75+ "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI",
76+ "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB",
77+ "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US"]
78+
79+ getAt : Nat -> List String -> Maybe String
80+ getAt Z (x :: xs) = Just x
81+ getAt (S k) (x :: xs) = getAt k xs
82+ getAt _ [] = Nothing
8083
8184showLitString : List Char -> String -> String
8285showLitString [] = id
@@ -221,9 +224,6 @@ instance Show a => Show (List a) where
221224 show' acc [x] = acc ++ show x
222225 show' acc (x :: xs) = show' (acc ++ show x ++ ", ") xs
223226
224−instance Show a => Show (Vect n a) where
225− show = show . toList
226−
227227instance Show a => Show (Maybe a) where
228228 show Nothing = "Nothing"
229229 show (Just x) = "Just " ++ show x
@@ -275,15 +275,6 @@ instance Applicative List where
275275
276276 fs <$> vs = concatMap (\f => map f vs) fs
277277
278−instance Applicative (Vect k) where
279− pure = replicate _
280−
281− fs <$> vs = zipWith apply fs vs
282−
283−instance Applicative Stream where
284− pure = repeat
285− (<$>) = zipWith apply
286−
287278---- Alternative instances
288279
289280instance Alternative Maybe where
@@ -316,12 +307,6 @@ instance Monad (Either e) where
316307instance Monad List where
317308 m >>= f = concatMap f m
318309
319−instance Monad (Vect n) where
320− m >>= f = diag (map f m)
321−
322−instance Monad Stream where
323− s >>= f = diag (map f s)
324−
325310---- Traversable instances
326311
327312instance Traversable Maybe where
@@ -332,10 +317,6 @@ instance Traversable List where
332317 traverse f [] = pure List.Nil
333318 traverse f (x::xs) = [| List.(::) (f x) (traverse f xs) |]
334319
335−instance Traversable (Vect n) where
336− traverse f [] = pure Vect.Nil
337− traverse f (x::xs) = [| Vect.(::) (f x) (traverse f xs) |]
338−
339320---- some mathematical operations
340321---- XXX this should probably go some place else,
341322pow : (Num a) => a -> Nat -> a
@@ -420,17 +401,6 @@ instance Enum Int where
420401 go [] = []
421402 go (x :: xs) = n + (cast x * inc) :: go xs
422403
423−instance Enum (Fin (S n)) where
424− pred FZ = FZ
425− pred (FS n) = weaken n
426− succ n = case strengthen (FS n) of
427− Left _ => last
428− Right k => k
429− toNat n = cast n
430− fromNat {n=n} m = case natToFin m (S n) of
431− Just k => k
432− Nothing => last
433−
434404syntax "[" [start] ".." [end] "]"
435405 = enumFromTo start end
436406syntax "[" [start] "," [next] ".." [end] "]"