# Re[8]: [stack] Joy, purely functional?

## Serguey Zefirov — 2001-12-14 13:44:08

    Hello Louis,

    ñðåäà, 12 äåêàáðÿ 2001 ã., you wrote:

    LM> Hi Serguey,

    LM> On Wednesday, December 12, 2001, at 12:23  AM, Serguey Zefirov wrote:

     >>

    >> So what type will have quotation [drop 3 + [-]] in your notation?

    >>

     LM> its still [[t]].  Its a very abstract notation that ignores lots of

    LM> details.  It wouldn't be useful for  what is normally considered type

    LM> checking.

    Okay, done. I still hope to see your type system.

     >> a (T x) (T y) (T z) = "This simple function will show you (in order of

    >> appearance):\n"++

    >>         "x : "++show x++"\n"++

    >>         "y : "++show y++"\n"++

    >>         "z : "++show z++"\n"

    >>

    >> testa = putStrLn $ a (T "Wow! x!") (T 10) (T $ Just "I am Z")

    >> ------------------------------------------

    >> It works with hugs 98. Save text between dashes into file a.hs, then

    >> run "hugs -98 a.hs", then type "testa <ENTER>".

     LM> Well ok, but this is not what I had in mind. 'printf' requires a format

    LM> string, eg: "read %d bytes from %s" and we want to ensure that the

    LM> programmer is passing the right types of subsequent arguments to match

    LM> up with it (an integer and string in this case). The approach you

    LM> describe would allow the wrong types to be passed.

    Nope, the only types passed are such that allow show'ing. They are

    completely right and very useful in the "a" context. I just do not

    need anything more than Show type class member here, and that's the

    way printf works. I may put a list of T's as an argument for a

    function "a" and get an equivalent for printf.

    This is just a matter of design, do you agree?

    LM> Notice that with existential types there is no way to check the

    LM> relationship between the format argument and the subsequent arguments

    LM> even at runtime (so while the type system remains decidable, it is only

    LM> type checking the program in a loose sense).

    --------------------------------------------

    data    Y       =

                    forall a . Show a => YShow a

            |       forall a . (Num a, Show a) => YNumShow a

    --------------------------------------------

    If I ever need a printf that need to increment some of the arguments

    (for example, to print a range of values).

    Best regards,

    Serguey Zefirov               mailto:sz@...