Skip to content

Instantly share code, notes, and snippets.

@oleks
Last active April 16, 2017 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oleks/b89b21aec02e89b52d2c7a93faa25510 to your computer and use it in GitHub Desktop.
Save oleks/b89b21aec02e89b52d2c7a93faa25510 to your computer and use it in GitHub Desktop.
Defining equality for a non-dependent type hosting a dependent type
module A
import Data.Vect
data T
= Val Int
| Vec (Vect len T)
vectEq : Eq a => Vect n a -> Vect m a -> Bool
vectEq {n} {m} v w = n == m && Just v == (exactLength n w)
Eq T where
(==) (Val i) (Val j) = i == j
(==) (Vec v) (Vec w) = vectEq v w
(==) _ _ = False
{-
A.idr:13:3:
Prelude.Interfaces.A.T implementation of Prelude.Interfaces.Eq, method ==
is possibly not total due to recursive path Prelude.Interfaces.A.T
implementation of Prelude.Interfaces.Eq, method == -->
Prelude.Interfaces.A.T implementation of Prelude.Interfaces.Eq, method ==
./Prelude/Interfaces.idr:30:5:
Prelude.Interfaces.A.T implementation of Prelude.Interfaces.Eq, method /=
is possibly not total due to: Prelude.Interfaces.A.T implementation of
Prelude.Interfaces.Eq, method ==
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment