Hi Denis,
thank you very much for your very nice answer, it definitely helps! I
completely forgot about the possibility of using GADTs to construct type
families---my bad!
Your solution makes sense to me, except that I don't completely
understand the necessity of the constructor `BadCase`. That is, one
might naively think that
```idris
data OnlyInt : Type -> Type where
NiceCase : OnlyInt Int
Foo OnlyInt where
bar {a=Int} @{NiceCase} = 0
```
should also do the trick, as this is clearly an exhaustive pattern match
on the auto-implicit variable. However if you try that, the type checker
gives the familiar complaint about non-coverage. I am not entirely sure
why that is or why it works with two constructors.
Btw, I actually made a mistake: the predicate should of course not be of
type `Type -> Type` but rather of type `Type -> Prop` where by `Prop` I mean
```idris
IsProp : Type -> Type
IsProp ty = (x : ty) -> (y : ty) -> (x = y)
Prop : Type
Prop = Subset Type IsProp
```.
My mistake was in thinking that since Idris' type system has UIP, all
types are propositions anyway, but of course that's not true: types are
only sets. Fortunately, your solution can be adapted easily:
```idris
data OnlyInt' : Type -> Type where
NiceCase : OnlyInt' Int
BadCase : Void -> OnlyInt' x
OnlyInt'_is_prop : (x : OnlyInt' ty) -> (y : OnlyInt' ty) -> x = y
OnlyInt'_is_prop {ty=Int} NiceCase NiceCase = Refl
OnlyInt'_is_prop (BadCase pf) y = absurd pf
OnlyInt : Type -> Prop
OnlyInt ty = Element (OnlyInt' ty) OnlyInt'_is_prop
```.
It's a bit verbose, but it works. Again, many thanks.
Best,
Nicolas
Am 27.01.21 um 10:53 schrieb Denis Buzdalov:
> --
> You received this message because you are subscribed to the Google
> Groups "Idris Programming Language" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
idris-lang+...@googlegroups.com
> <mailto:
idris-lang+...@googlegroups.com>.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/idris-lang/CAP77jwW%3DeSw%3DTzwVup1d8aQOrg_TNKAtxC3Lpbd1N1a1pa3mnA%40mail.gmail.com
> <
https://groups.google.com/d/msgid/idris-lang/CAP77jwW%3DeSw%3DTzwVup1d8aQOrg_TNKAtxC3Lpbd1N1a1pa3mnA%40mail.gmail.com?utm_medium=email&utm_source=footer>.