[Haskell-beginners] Check constructor's field numeric value at compile time

Brandon Allbery allbery.b at gmail.com
Wed Sep 3 03:07:31 UTC 2014


On Tue, Sep 2, 2014 at 11:04 PM, Kim-Ee Yeoh <ky3 at atamo.com> wrote:
>
> On Wed, Sep 3, 2014 at 3:58 AM, Alexandre Lucchesi <
> alexandrelucchesi at gmail.com> wrote:
>
>> In order to add such constraints you should define "constructor
>> functions" and apply the validation there, i.e.:
>
>
> To OP: Yes, the searchable term is "smart constructors". However, it has
> been used at least once on this list to mean something different, so look
> out.
>

Also note that this will not actually check at compile time; to do that you
need type level stuff that ghc is still finding its way through.

-- 
brandon s allbery kf8nh                               sine nomine associates
allbery.b at gmail.com                                  ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140902/87d73d10/attachment-0001.html>


More information about the Beginners mailing list