[Haskell-cafe] Manual type-checking in graphs: Avoidable?
fa-ml at ariis.it
Fri Feb 19 04:36:59 UTC 2016
On Thu, Feb 18, 2016 at 06:50:26PM -0800, Jeffrey Brown wrote:
> Suppose then you wanted to write a function that, given a person, returns
> the names of all their hamsters. To make sure the call makes sense, the
> function would have to first check that the input is in fact a person.
> Since persons and hamsters are both constructors of the same type, you
> can't let Haskell's robust, beautiful type-checking system distinguish them
> for you; you've got to write something like "case n of Person _ -> True; _
> -> False".
> Is there some way around writing such manual checks?
have you considered using Phantom types ?
More information about the Haskell-Cafe