[Ur] Structure within let

Nitin Surana nsurana at usc.edu
Thu Nov 9 04:10:59 EST 2017


Hi

I'm trying to define a structure within let block but it fails. Having the
structure outside works perfectly fine.

sample.ur

fun main()=
let

    fun debugMe a =
            alert a


    structure AB = Mymaths.Make(struct
                                   val callback = debugMe
                               end)

    fun callMe () =
        x <- AB.simple "test";
        debug x

in
    return <xml>
        <body>
            <h1> Sample </h1>
            <button value="Click Me" onclick={fn _ => callMe()}></button>
        </body>
        </xml>
end


Above code throws compile error, where as the following code compiles &
runs fine :

fun debugMe a =
            alert a

    structure AB = Mymaths.Make(struct
                                   val callback = debugMe
                               end)

fun main()=
let
    fun callMe () =
        x <- AB.simple "test";
        debug x

in
    return <xml>
        <body>
            <h1> Sample </h1>
            <button value="Click Me" onclick={fn _ => callMe()}></button>
        </body>
        </xml>
end


Any idea what's going wrong ? Can't a structure be created within let ? If
no, then is there an alternative ?


-- 
Regards
Nitin Surana
MS Computer Science
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.impredicative.com/pipermail/ur/attachments/20171109/4a57159b/attachment.html>


More information about the Ur mailing list