[Haskell-cafe] question on types
Lennart Augustsson
lennart at augustsson.net
Wed Feb 18 05:12:59 EST 2009
Also, if you are using ghc you can turn on the extension that allows
undecidable instances and make the type system Turing complete.
-- Lennart
On Wed, Feb 18, 2009 at 10:08 AM, Stephan Friedrichs
<deduktionstheorem at web.de> wrote:
> Daryoush Mehrtash wrote:
>> Is there a way to define a type with qualification on top of existing
>> type (e.g. prime numbers)? Say for example I want to define a
>> computation that takes a prime number and generates a string. Is there
>> any way I can do that in Haskell?
>
> Haskell's type system is decidable, so you can't let the type system
> check arbitrary properties. It probably is possible in C++ by some
> template hack (C++ templates are Turing complete), but not in Haskell.
> But, as mentioned in the other responses, you can
>
> - use a representation that makes it impossible to use wrong values
> (-> Ketil's n-th prime representation)
>
> - check values at runtime (-> Luke's repsonse)
>
> //Stephan
>
> --
>
> Früher hieß es ja: Ich denke, also bin ich.
> Heute weiß man: Es geht auch so.
>
> - Dieter Nuhr
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
More information about the Haskell-Cafe
mailing list