[Ur] Unsupported expression

Marco Maggesi maggesi at math.unifi.it
Wed Jan 4 10:48:56 EST 2017


Dear Adam,

thank you for the quick answer.

Marco


2017-01-04 13:39 GMT+01:00 Adam Chlipala <adamc at csail.mit.edu>:
> On 01/04/2017 05:40 AM, Marco Maggesi wrote:
>>
>> I'm trying to figure out what is wrong with this program:
>>
>> fun mapseq [m ::: Type -> Type] (_ : monad m) [t ::: Type]
>>             (f : t -> m unit) (ls : list t)
>>    : m unit
>>    = case ls of
>>       [] => return ()
>>     | h :: t => f h; mapseq f t
>>
>> val l = "a" :: "b" :: "c" :: []
>>
>> fun main () =
>>    mapseq (fn s => debug s) l;
>>    return <xml/>
>
>
> Shallow answer: that function is already in the standard library as
> [List.app], and it will work in your example if used instead of [mapseq].
>
> Deeper answer: you've run into the general heuristic nature of the compiler
> optimizations to remove all uses of polymorphism, where the compiler will
> give up if any polymorphism remains in the end, in server-side code.  These
> optimizations generally work best when all of a function's type parameters
> appear before any value parameters. So, swapping [t] and the [monad]
> argument does the trick (without requiring any changes to the actual calls).
>
> _______________________________________________
> Ur mailing list
> Ur at impredicative.com
> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur



More information about the Ur mailing list