Opa: Up and Running by Henri Binsztok Adam Koprowski & Ida Swarczewskaja
Author:Henri Binsztok, Adam Koprowski & Ida Swarczewskaja
Language: eng
Format: epub, pdf
Tags: COMPUTERS / Web / Web Programming
ISBN: 9781449328801
Publisher: O’Reilly Media
Published: 2013-02-26T05:00:00+00:00
That seems like a useful definition, but we may need null for values of types other than just int. Repeating it for every single type where we need this feature would be terribly inefficient.
Fortunately, we can do better. Here is a definition from the standard Opa library:
type option('a) = {none} or {'a some}
Here, 'a is a type variable (type variables always begin with a single apostrophe) and the definition of option is parameterized by this type variable. It has two variants: {none}, meaning no value, and {some: x}, representing an existing value x of the parameterized type 'a.
We call such a type a polymorphic type as we can substitute the type variable, 'a, with an arbitrary type to obtain a concrete type. For instance, you can get optional integers by instantiating 'a with int to obtain option(int).
Also note that, thanks to Opa’s type inference, you will not need to spell out the type names in many cases. If you just write {some: 5}, the compiler will be able to figure out that this is a value of type option(int).
It’s important to realize that you can also write polymorphic functions like this one:
Download
Opa: Up and Running by Henri Binsztok Adam Koprowski & Ida Swarczewskaja.pdf
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
The Mikado Method by Ola Ellnestam Daniel Brolund(26290)
Hello! Python by Anthony Briggs(25216)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(24446)
Kotlin in Action by Dmitry Jemerov(23535)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(22880)
Dependency Injection in .NET by Mark Seemann(22667)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(21430)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(20273)
Grails in Action by Glen Smith Peter Ledbrook(19343)
Adobe Camera Raw For Digital Photographers Only by Rob Sheppard(17056)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(16366)
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(14077)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(12255)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(11533)
A Developer's Guide to Building Resilient Cloud Applications with Azure by Hamida Rebai Trabelsi(10643)
Hit Refresh by Satya Nadella(9219)
The Kubernetes Operator Framework Book by Michael Dame(8579)
Exploring Deepfakes by Bryan Lyon and Matt Tora(8432)
Robo-Advisor with Python by Aki Ranin(8376)