Proposal: Add bool to Data.Bool
Edward Kmett
ekmett at gmail.com
Wed Sep 11 20:26:53 CEST 2013
I'm also rather against `mux`, not only on partiality grounds, but also on
the grounds that it is not very easily optimized away.
On Wed, Sep 11, 2013 at 2:23 PM, Henning Thielemann <
lemming at henning-thielemann.de> wrote:
>
> On Wed, 11 Sep 2013, Greg Fitzgerald wrote:
>
> I'd prefer something more like:
>>
>> mux :: Enum b => [a] -> b -> a
>> mux xs x = xs !! fromEnum x
>>
>> so then 'bool' could be implemented as:
>>
>> bool :: a -> a -> Bool -> a
>> bool f t = mux [f, t]
>>
>> but 'mux' needs a stronger type signature. The size of the enum is
>> known at compile-time. Is there any way to constrain the input list
>>
>
> I don't like a total function to be implemented using a non-total function
> (!!). Additionally your implementation relies on fromEnum True == 1, which
> is a bad thing.
>
> ______________________________**_________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/**mailman/listinfo/libraries<http://www.haskell.org/mailman/listinfo/libraries>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20130911/2581fe93/attachment.htm>
More information about the Libraries
mailing list