Tutorial by Examples: e

Intuition The categorical product of two types A and B should contain the minimal information necessary to contain inside an instance of type A or type B. We can see now that the intuitive coproduct of two types should be Either a b. Other candidates, such as Either a (b,Bool), would contain a part...
(This example copied from this StackOverflow answer) Let's say you have a number of different data types that all ought to have a lens with the same name, in this case capacity. The makeFields slice will create a class that accomplish this without namespace conflicts. {-# LANGUAGE FunctionalDepen...
First thing to do is enable the mod rewrite on wamp go to Apache modules and scroll down the list If not showing tick enable it and then restart all servers. Linux users can also use below terminal command to enable rewrite module sudo a2enmod rewrite Then restart apache using: sudo service...
Chaining and Chainable is a design methodology used to design object behaviors so that calls to object functions return references to self, or another object, providing access to additional function calls allowing the calling statement to chain together many calls without the need to reference the v...
Paste your fonts file inside android/app/src/main/assets/fonts/font_name.ttf Recompile the Android app by running react-native run-android Now, You can use fontFamily: 'font_name' in your React Native Styles
Cost centers are annotations on a Haskell program which can be added automatically by the GHC compiler -- using -fprot-auto -- or by a programmer using {-# SCC "name" #-} <expression>, where "name" is any name you wish and <expression> is any valid Haskell expression:...
Check screencast video on YouTube about this feature IntelliJ provides a quick-preview feature called Viewing Definition. Using this feature allows a user to quickly see the contents of a method/class without navigating into the class itself OS X - (⌘+Y) or (⌥+Space) Unix / Windows - Ctrl+Shif...
SQL Server 2008 R2 Supported compound operators: += Add and assign -= Subtract and assign *= Multiply and assign /= Divide and assign %= Modulo and assign &= Bitwise AND and assign ^= Bitwise XOR and assign |= Bitwise OR and assign Example usage: DECLARE @test INT = 42; SET @test...
A class is also allowed to have static members, which can be either variables or functions. These are considered to be in the class' scope, but aren't treated as normal members; they have static storage duration (they exist from the start of the program to the end), aren't tied to a particular inst...
Join parent objects with their child entities, for example we want a relational table of each person and their hobbies DECLARE @json nvarchar(1000) = N'[ { "id":1, "user":{"name":"John"}, "hobbies":[ {...
When you also want to expose metadata without a config file you can build on the example programmatically creating a ServiceHost: public ConsoleHost() { mHost = new ServiceHost(typeof(Example), new Uri("http://localhost:8000/Example"), new Uri("net.tcp://9000/Example")); ...
Scope guards allow executing statements at certain conditions if the current block is left. import core.stdc.stdlib; void main() { int* p = cast(int*)malloc(int.sizeof); scope(exit) free(p); }
import std.stdio; void main() { writeln("<html>"); scope(exit) writeln("</html>"); { writeln("\t<head>"); scope(exit) writeln("\t</head>"); "\t\t<title>%s</title>".write...
Here we have a simple class to be tested that returns a Promise based on the results of an external ResponseProcessor that takes time to execute. For simplicty we'll assume that the processResponse method won't ever fail. import {processResponse} from '../utils/response_processor'; const ping =...
Selective imports can help to cleanup the namespace and speed-up the compile-time even more, because the compiler only needs to parse the specific, selected functions. import std.stdio: writeln; void main() { writeln("Hello world"); }
A local name for an import can be given, through which all references to the module's symbols must be qualified with: import io = std.stdio; void main() { io.writeln("Hello world"); std.stdio.writeln("hello!"); // error, std is undefined writeln("hello!&qu...
Selective imports may also be renamed. void main() { import std.stdio : fooln = writeln; fooln("Hello world"); }
Modules have a one-to-one correspondence with source files. The module name is, by default, the file name with the path and extension stripped off, and can be set explicitly with the module declaration. The ModuleDeclaration sets the name of the module and what package it belongs to. If absent, the...
You can move a container instead of copying it: void print(const std::vector<int>& vec) { for (auto&& val : vec) { std::cout << val << ", "; } std::cout << std::endl; } int main() { // initialize vec1 with 1, 2, 3, 4 and...
You can re-use a moved object: void consumingFunction(std::vector<int> vec) { // Some operations } int main() { // initialize vec with 1, 2, 3, 4 std::vector<int> vec{1, 2, 3, 4}; // Send the vector by move consumingFunction(std::move(vec)); // Here...

Page 518 of 1191