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 [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
