For note, you can and should still type all of that, foo could be typed:
```elm
foo : { x : Int } -> Int
-- Or even looser:
foo : { x : a } -> a
```
If, however, foo only ever takes a User then User should be specified to
help constrain it. But if foo is generic enough (like yours above), then
no point unless it really is User-specific.
However, I do not personally like it, types are as much documentation as
they are for the compiler.
On Monday, September 12, 2016 at 9:54:58 AM UTC-6, Ashish Negi wrote:
>
> -- I was discussing with my colleague today about Elm and
> -- i asked him about his points about static typing..
> -- He said that it is difficult to write tests in static langs as
> -- duck typing is easier in dynamic languages.
>
> — I wrote some code to counter his point :
> type alias User =
> { x : Int
> , y : Int
> }
>
> foo p = p.x
>
> — app code
> v = foo (User 1 2)
>
> — test code --
> z = foo { x = 3 }
>
> ```
> This code counters his point `BUT`
> one has to stop writing `type declarations` for functions altogether or
> just specify the used variables like
> `foo : { x : Int } -> Int`
> in above case..
>
> What does community think about this ?
>
--
You received this message because you are subscribed to the Google Groups "Elm
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.