Skip to content

Commit 0bd29d5

Browse files
committed
copilot-core: Add Show instance for Type. Refs #589.
Currently, the `Copilot.Theorem.What4.prove` function returns a list of results, where each result contains a `SatResult` that describes whether a property is `Valid`, `Invalid`, or `Unknown`. The `Invalid` result has the limitation that it does not give any information about a specific counterexample that could drive Copilot into falsifying the property, however. This makes it challenging to interpret what the results of prove mean. To define a companion function to `prove` that also returns counterexample information upon a failed proof, it is convenient to be able to display `Type` information in panic messages. This commit derives a basic `Show` instance for `Type` so that `copilot-theorem` can display them whenever an internal invariant is violated.
1 parent e234f1b commit 0bd29d5

File tree

1 file changed

+2
-0
lines changed
  • copilot-core/src/Copilot/Core

1 file changed

+2
-0
lines changed

copilot-core/src/Copilot/Core/Type.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
{-# LANGUAGE GADTs #-}
66
{-# LANGUAGE KindSignatures #-}
77
{-# LANGUAGE ScopedTypeVariables #-}
8+
{-# LANGUAGE StandaloneDeriving #-}
89
{-# LANGUAGE Trustworthy #-}
910
{-# LANGUAGE TypeApplications #-}
1011
{-# LANGUAGE TypeOperators #-}
@@ -154,6 +155,7 @@ data Type :: * -> * where
154155
, Typed t
155156
) => Type t -> Type (Array n t)
156157
Struct :: (Typed a, Struct a) => a -> Type a
158+
deriving instance Show (Type a)
157159

158160
-- | Return the length of an array from its type
159161
typeLength :: forall n t . KnownNat n => Type (Array n t) -> Int

0 commit comments

Comments
 (0)