This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Container f1 f2 f3 = | |
| { children :: f1 String | |
| , friends :: f2 Int | |
| , colleagues :: f3 Number | |
| } | |
| data SomeType f1 f2 f3 a e = Container (Container f1 f2 f3) | |
| | AnotherType a | |
| | SomeEffect (Eff e Unit) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Html exposing (beginnerProgram, div, button, text, ul, li, input, Html) | |
| import Html.Events exposing (onClick, onInput) | |
| import Array exposing (Array, toList, fromList, push, filter) | |
| main = | |
| beginnerProgram { model = initialState, view = view, update = update } | |
| type alias Model = { list: Array String, currentText: String } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val nameStream = createInputHandler() | |
| val component = div( | |
| label(className := "label", "Name:"), | |
| input(inputType := "text", input --> nameStream), | |
| hr(), | |
| h1("Hello ", child <-- nameStream) | |
| ) | |
| render(document.getElementById("app"), component) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //So now after letting IntelliJ convert our file to Kotlin we get this: | |
| //... but there's an error | |
| class ExampleActivity : AppCompatActivity() { | |
| private var foo: String? = "Bar" | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_main) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ExampleActivity extends AppCompatActivity { | |
| private String foo = "Bar"; | |
| @Override | |
| public void onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.activity_main); | |
| foo = getSomething(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| trait Functor[F[_]] { | |
| def fmap[A, B](f: A => B): F[A] => F[B] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val res = arr match { | |
| case Array(0) => "0" | |
| case Array(x, y) => x + " > " + y | |
| case Array(0, _*) => "0 > ..." | |
| case _ => "..." | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val list = Stream(1,2,3,4,5,6,7,8,9) | |
| val list2 = list.map(_ + 8) | |
| .filter(_ % 2 == 0) | |
| .map(_ * 4) | |
| println(list2.head) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var arr = [1,2,3,4,5,6,7,8,9] | |
| var arr2 = arr.map(x => x + 8) | |
| .filter(x => x % 2 == 0) | |
| .map(x => x * 4) | |
| console.log(arr2[0]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add :: Integer -> Integer -> Integer | |
| add a b = a + b |