It seems square brackets are closely associated with lists, so would:
f s = ({ c | c <- (s :: String) } :: String)
Be better. Note, I think in Haskell type annotations must always be
enclosed by brackets, so that may be expected.
Keean.
On 10 February 2015 at 17:51, Jonathan S. Shapiro <[email protected]> wrote:
> On Mon, Feb 9, 2015 at 7:37 PM, Matt Rice <[email protected]> wrote:
>
>> On Mon, Feb 9, 2015 at 3:03 PM, Jonathan S. Shapiro <[email protected]>
>> wrote:
>> >
>> > So what kind of comprehension is the example I gave:
>> >
>> > [ c | c <- s : String ]
>> >
>> >
>> > because it seems to me that the input here is a String and the output
>> is a
>> > list of characters. Is this a string comprehension, a list
>> comprehension, or
>> > some third thing?
>>
>> It seems to me that it'd be a list comprehension, because a string (as
>> the output collection) is not generally incrementally constructed...
>
>
> It took me a while to figure out what you meant here. I'm afraid that
> wasn't the precedence I intended. What I intended was:
>
> [ c | c <- (s : String) ]
>
>
> That is: we are forming a list of characters obtained by exploding a
> string. Naively, I would have expected that since the thing being
> comprehended (so to speak) is a string, this would be considered a string
> comprehension.
>
> But your reading raises another question that I should ask. In BitC, type
> qualification (the s:String) binds with high precedence. I think you
> assumed in your reading that it was binding with low precedence. What is
> the convention in Haskell and O'Caml regarding the precedence of type
> qualification of this form?
>
>
> shap
>
> _______________________________________________
> bitc-dev mailing list
> [email protected]
> http://www.coyotos.org/mailman/listinfo/bitc-dev
>
>
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev