From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Mark Carroll Newsgroups: comp.lang.ada Subject: Re: Haskell, anyone? Date: Sun, 15 Nov 2015 23:05:09 +0000 Organization: none Message-ID: <87mvue50ey.fsf@ixod.org> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="1b3e5cba9e4d07a53741e6f3d1717925"; logging-data="9186"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19mBeAYu7P5KRjJIkxO9M/X" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Cancel-Lock: sha1:Ur3F4ppNekSs7NhUeoMZXSZPx90= sha1:1jT5naaduqoUeuizfK9WSRr4d7k= Xref: news.eternal-september.org comp.lang.ada:28377 Date: 2015-11-15T23:05:09+00:00 List-Id: On 15 Nov 2015, Nasser M. Abbasi wrote: (snip) > On Ada, One of the best features is the ability to define subtypes very > easily. I have not seen any other language with this feature. (one has > to make Class in other languages, and define all the operations each time). > > This is for me what makes Ada for me. One can define a type > that matche the range of the physical quantity being modeled. > This helps catch many errors. > > Can one do this in Haskell? Say define a new integer subtype that > can only take values from only 1...20. And have the compiler > and run time check for this? One could do subrange types back with Modula-3 too! (Possibly also earlier Pascal-like languages.) I /can't/ think off-hand how to do this easily with Haskell (at least without unusual extensions) but I /think/ that Idris, that I'd mentioned as illuminating a possible way forward, would probably make you work a bit harder for subtypes, in the theorem proving for dependent types, but with the payback of allowing a rather wider range of kinds of subtype constraint. Unfortunately the leading edge of compiler-checked correctness still makes one sweat for that final thumbs-up. -- Mark