[
http://dev.sourcefabric.org/browse/LS-617?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
David Baelde updated LS-617:
----------------------------
Summary: Type annotation on variable introductions (let and function
arguments) (was: We need type annotations..)
> Type annotation on variable introductions (let and function arguments)
> ----------------------------------------------------------------------
>
> Key: LS-617
> URL: http://dev.sourcefabric.org/browse/LS-617
> Project: Liquidsoap
> Issue Type: New Feature
> Affects Versions: 1.0
> Reporter: Romain Beauxis
> Priority: Important
>
> Here's why:
> # def apply(f, x) = f(x=x) end;;
> apply : (((x:'a)->'b),'a)->'b = <fun>
> # def optional(~x="f") = "f" end;;
> optional : (?x:string)->string = fun (~x="f") -> "f"
> # apply(optional, "foo");;
> At line 316, char -125:
> this value has type
> (?x:_)->_ (infered at line 316, char -139--110)
> but it should be a subtype of (the type of the v
> In OCaml:
> # let apply f x = f ~x:x ;;
> val apply : (x:'a -> 'b) -> 'a -> 'b = <fun>
> # let optional ?(x="foo") = x;;
> Warning 16: this optional argument cannot be erased.
> val optional : ?x:string -> string = <fun>
> # apply optional "gni";;
> Error: This expression has type ?x:string -> string
> but an expression was expected of type x:'a -> 'b
> BUT:
> # let apply (f : ?x:'a -> 'b) x = f ~x:x ;;
> val apply : (?x:'a -> 'b) -> 'a -> 'b = <fun>
> # apply optional "gni";;
> - : string = "gni"
> In case you're wondering, I have a much more useful example that cannot work
> without that...
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://dev.sourcefabric.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Savonet-devl mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-devl