Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm not sure this is the reason, but function types look better if you put the return type after the parameter types. Compare C to Kotlin:

    float (* f)(int);
    val f : (int) -> float;
    float[] (* map)(int[], float (*)(int));
    val map : (int[], (int) -> float) -> float[]
You could put the return type before the function, but then the type will look inconsistent with the function declaration:

    float[] map(int[] arr, (int) -> float f)
    fun map(arr : int[], f : (int) -> float) : float[]
So if you're passing functions around, it tends to look nicer if you always put the type after the variable/argument/function


Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: