3

According to idris Show Int is a type.

*main> :t Show Int
Show Int : Type

What is of an example of a value that has that type?

*main> :t ?
? : Show Int

What could I replace ? with to get that behavior?

I found the answer to my question here: In Idris, is "Eq a" a type, and can I supply a value for it?

Anton Trunov
  • 15,074
  • 2
  • 23
  • 43
michaelmesser
  • 3,601
  • 2
  • 19
  • 42

1 Answers1

2

It is this single instance of the Show typeclass

Show String where
show cs = strCons '"' (showLitString (cast cs) "\"")

defined in Prelude/Show.idr where the typeclass is also defined

Markus
  • 1,293
  • 9
  • 10
  • After reading your answer I am still not sure what values if any have a type of `Show Int`. I understand how type classes work in Haskell. In Haskell `Show` is a `* -> Constraint` (which makes sense to me) but in Idris `Show` is `Type -> Type` (which confuses me). – michaelmesser Sep 09 '17 at 11:55
  • http://docs.idris-lang.org/en/latest/tutorial/interfaces.html Maybe this helps: Show String is the implementation and hence value of the interface Show: Type -> Type – Markus Sep 09 '17 at 11:58
  • AFAIK you can't ask the REPL for that. Implementations for interfaces are a bit different to normal instances of Types, as the compiler makes sure that there is always only one of them. You can however give implementations a name: http://docs.idris-lang.org/en/latest/tutorial/interfaces.html#named-implementations – Markus Sep 09 '17 at 12:06
  • 1
    I found the answer I was looking for here https://stackoverflow.com/a/44347094/6369276 – michaelmesser Sep 09 '17 at 12:07
  • 2
    Thanks for sharing, nice trick! ` :t {auto inst: Show String} -> Show String` is almost what you wanted. For more my idris foo is not sufficient. – Markus Sep 09 '17 at 12:13
  • 1
    you can also just use `%implementation` to run a search – Alexander Gryzlov Nov 24 '17 at 11:55