[Haskell-cafe] Type trickery

Luke Palmer lrpalmer at gmail.com
Wed Mar 16 21:03:51 CET 2011


On Wed, Mar 16, 2011 at 7:52 AM, Andrew Coppin
<andrewcoppin at btinternet.com> wrote:
>>> Hmm, yes. That will work, but I wonder if there's some way of doing this
>>> that doesn't limit the scope of the container to one single span of
>>> code...
>>
>> You can write helper functions which take containers as argument by
>> parameterizing these helper functions over s:
>>
>> takesTwoContainers :: Container s1 -> Container s2 -> ...
>> takesTwoContainers c1 c2 = ... -- c1 and c2 can be used here
>>
>> This function could be called like this:
>>
>> withContainer (\c1 ->
>> withContainer (\c2 ->
>> takesTwoContainers c1 c2)) -- c1 and c2 can be used here
>>
>> In this example, the scope of the containers is not limited to a single
>> span of code.
>
> What you can't do is write functions such as
>
>  foo :: Container x -> (Cursor x, Cursor x)
>
> for example.

I don't follow.

foo = cursor &&& cursor

Did you mean to have some extra condition on foo that can't be satisfied?

Luke



More information about the Haskell-Cafe mailing list