@@ -222,6 +222,26 @@ data GenericSpine
222222 | SArray (Array (Unit -> GenericSpine ))
223223 | SUnit
224224
225+ instance showGenericSpine :: Show GenericSpine
226+ where
227+ show SUnit = " SUnit"
228+ show (SChar c) = " SChar " <> show c
229+ show (SString s) = " SString " <> show s
230+ show (SBoolean b) = " SBoolean " <> show b
231+ show (SNumber n) = " SNumber " <> show n
232+ show (SInt i) = " SInt " <> show i
233+ show (SArray arr) = " SArray " <> showArray showSuspended arr
234+ show (SProd lbl arr) = " SProd " <> show lbl <> " "
235+ <> showArray showSuspended arr
236+ show (SRecord arr) = " SRecord " <> showArray showElt arr
237+ where
238+ showElt { recLabel: label, recValue: value } =
239+ fold [" { recLabel: " , show label, " , recValue: " , showSuspended value, " }" ]
240+
241+ -- | Shows a lazily evaluated value under a function with `Unit` parameter.
242+ showSuspended :: forall a . Show a => (Unit -> a ) -> String
243+ showSuspended e = " \\ _->" <> show (e unit)
244+
225245instance eqGenericSpine :: Eq GenericSpine where
226246 eq (SProd s1 arr1) (SProd s2 arr2) =
227247 s1 == s2 && length arr1 == length arr2 && zipAll eqThunk arr1 arr2
@@ -349,6 +369,7 @@ showSignature sig =
349369-- We use this instead of the default Show Array instance to avoid escaping
350370-- strings twice.
351371showArray :: forall a . (a -> String ) -> Array a -> String
372+ showArray _ [] = " []"
352373showArray f xs = " [ " <> intercalate " , " (map f xs) <> " ]"
353374
354375showLabel
@@ -473,3 +494,4 @@ orderingToInt = case _ of
473494 EQ -> 0
474495 LT -> 1
475496 GT -> -1
497+
0 commit comments