Herramientas de usuario

Herramientas del sitio


wiki2:elm

Diferencias

Muestra las diferencias entre dos versiones de la página.

Enlace a la vista de comparación

Ambos lados, revisión anterior Revisión previa
Próxima revisión
Revisión previa
wiki2:elm [2020/05/11 18:25]
alfred [Pattern matching]
wiki2:elm [2020/05/16 11:53] (actual)
Línea 160: Línea 160:
 </​code>​ </​code>​
  
 +=== Constructing records from another === 
 +<​code>​ 
 +> type alias A = { a: String, b: Int } 
 +> type alias B = { a: String, b: Int } 
 +> a : A 
 +| a = A "​prueba"​ 666 
 +{ a = "​prueba",​ b = 666 } : A 
 +> b : B 
 +| b = a 
 +{ a = "​prueba",​ b = 666 } : B 
 +</​code>​
 ==== Type annotation ==== ==== Type annotation ====
  
Línea 235: Línea 245:
 Visitor "​kate95"​ Visitor "​kate95"​
 -- Visitor "​kate95"​ : User -- Visitor "​kate95"​ : User
 +</​code>​
 +
 +=== Types variable ===
 +
 +When you do not care about the type that is passed. In the next example the ''​List''​ passed to ''​List.length''​ can be a ''​List String'',​ ''​List Int''​...
 +<​code>​
 +> List.length
 +<​function>​ : List a -> Int
 +</​code>​
 +
 +However it can restrict the output. With ''​List.reverse''​ we know that we are going to obtain a ''​List''​ with the same type as it was passed on the first instance.
 +<​code>​
 +> List.reverse
 +<​function>​ : List a -> List a
 +> List.reverse [ "​a",​ "​b",​ "​c"​ ]
 +["​c","​b","​a"​] : List String
 +> List.reverse [ True, False ]
 +[False,​True] : List Bool
 </​code>​ </​code>​
  
wiki2/elm.1589221523.txt.gz · Última modificación: 2020/05/11 19:25 (editor externo)