images

Index

images A

Abstract keyword, 127

Abstract members, 135

Abstract syntax implementations, 214216

Abstract syntax representations

caching properties, 208

flatten, 204205

mapping transformation, 205206

memoizing construction, 208210

pros and cons, 204

syntax type design, 204

using on-demand computation, 206207

Abstract syntax trees (ASTs), 178

drawing namespace, 178

extractScenes, 179180

inferred types, 179

XML conversion, 178179

Accumulating and rewriting transformations, 205

Accumulating functions, 47

Accumulating parameter, 224

Action.Login, 371

Activation records, 515

Active patterns, 174

converting same data to many views, 211213

hiding abstract syntax implementations, 214216

matching on .NET object types, 213214

.NET Library Design Guidelines and, 579

partial and parameterized active patterns, 214

adb.exe, 419

ADO.NET, 347351

agent.Post(message), 286

agent.Receive(?timeout), 286

Agents. See MailboxProcessor

agent.Scan(scanner, ?timeout), 286

agent.TryReceive(?timeout), 286

agent.TryScan(scanner, ?timeout), 286

Aggregate operators, 191192

Anchoring control, 432

Application store, 391392

Arithmetic expressions, error estimation , 499501

Arithmetic operators, 234

Array2D module, 59

ASCII character encoding, 175

AsyncAccept, 279

AsyncAcquire method, 290

Async.AwaitTask(task), 278, 280

Async.Catch combinator, 281

AsyncExecuteReader, 279

AsyncExecuteXmlReader, 279

Async.FromBeginEnd(beginAction, endAction), 278

Async.FromContinuations(callback), 278

AsyncGetResponse, 279

Asynchronous and parallel computations

Async type methods, 278279

cancellation checking, 274

common constructs used, 274, 275

common I/O operations, 279

exception propagation, 273274

exceptions and cancellation, 280281

fetching multiple Web pages, 270272

fork-join parallel operator implementation, 281

in CPU parallelism, 282

parallel file processing

asynchronous image processor, 276278

primitives and combinators, 278

synchronous image processor, 275276

resource lifetime management, 274

thread hopping, 272273

using tasks, 280

Asynchronous programs, 258

Asynchronous Web crawling, 287290

Async.Parallel(computations), 278

AsyncRead, 279

AsyncReceive, 279

Async.RunSynchronously(async), 278

AsyncSend, 279

Async.StartAsTask(computation), 280

Async.Start(async), 278

Async.StartChild(async), 279

Async.StartImmediate(async), 279

AsyncWrite, 279

AsynExecuteNonQuery, 279

Attribute types

custom attributes and, 495, 496

.NET types, 100

Automatic generalization, 45

Automatic memory, 514

AxisColor property, 445

AxShockwaveFlashObjects, 520

images B

Background Workers

building iterative worker, 264267

GUI connection, 268270

primary object members, 262, 263

raising GUI-thread events, 267268

simple use of, 262263

two-faced object, 263

Berkeley Database (BDB), 534

bigint type, 234

Binary comparison operators, 27

Binary data, 176

Binary decision diagrams (BDD), 296

circuit verification, 307

Equiv, 306

implementation, 304306

language representation techniques, 304

logical rules, 306

mkAnd operation, 306

pretty-printer installation, 306307

Prop representation, 306, 307

ToString member, 306

Binary operators, 46

BinaryReader, 68

Binary serialization, 9294

BinaryWriter, 67

Binary XAML (BXAML), 468

Bitwise operations, 236237

Boolean-valued expression, 28

Bool type, 233

Bottom-up rewriting, 205

box function, 9192

binary serialization, 92, 93

.NET types, 99

builder, for workflows, 478, 483–485, 488

byte

literal byte arrays and, 164

operator, 235

images C

C5 collection library, 509

Callbacks model, 46

Cancellation checking, 274

CAPTCHA validation, 409

Case insensitivity, 173, 574

Close operation, 68

Closure, 43

Code

implementation code and, 580

signature

command-line compiler, 154

design, 156

explicit signature type, 155

file vector.fs, 155

.fsi file extension, 155

inferred type, 154, 155

type-inference process, 156

Code encapsulation and organization

accessibility annotation

checkVisitor function, 150

code restriction, 150

F# code, 151

GlobalClock module, 151

internal state, 151

property setters, 152

table protection, 150

code reusage

code compilation, 159

DLLs, 159

executable programs, 159

file dolphins.fs, 160

file whales.fs, 160

file whalewatcher.fs, 161

F# programming progress, 158

reusable components, 159

sharing and packaging mechanism, 161162

encapsulation boundaries, 147

local definiton

count state, 148

inferred types, 149

IPeekPoke, 148

IStatistic type, 149

let bindings, 148, 149

mutable state count, 149

variable count, 149

namespace and modules

attribute addition, 156

AutoOpen attribute, 158

client code prevention, 156

container types, 152, 153

definition, 154

explicit initial module declaration, 157

F# code fragments, 157

qualified names, 152

signature (see Code signature)

Vector2D, 153

.NET assembly, 147

packaging code, 147

Coercion operator, 101

collectLinks function, 289

COM callable wrapper (CCW), 518

Common Intermediary Language (CIL), 568

Common Language Runtime (CLR), 503, 512514

Comparison operators, 89, 235

CompiledName attribute, 371

Component Object Model (COM)

characteristics, 516

Flash Player, 519520

F# program

compiler, 517

F# and fsi.exe, 516517

GetType method, 517

Quit method, 517

SetValue method, 517

.NET classes, 518

.NET components, 518

COM callable wrapper, 518

programming pattern, 518

runtime callable wrapper, 518

running object table

Marshal class, 521

Visual Studio, 521, 522

Composite formatting, 167

Compositional constructs, 571

Computation expressions. See Workflows

Computations

delayed, 486

precomputation and, 496

Compute bound application, 275

Concrete language format

ASTs

drawing namespace, 178

extractScenes, 179180

inferred types, 179

XML conversion, 178179

System.XML namespace

data sharing, 176

hierarchical structure, 176

interactive function, 177

sample fragment, 176

types and members, 177

Concrete representations, .NET Library Design Guidelines and, 579

Concurrency objects, 136

Concurrent programs, 258

&& conditionals operator, 28

|| conditionals operator, 28

Connection strings, databases and, 347

Console.In, 103

Construction sequences, 116

Constructors, 116, 124

Explicit constructors and, 117

functions, 20

Content constructors, 366

Content.CustomContent, 367

Content.PageContent, 367

Continuation passing, 226228

Conversion operators, 26, 235

convertToFloatAndAdd, 98

Copy collection, 515

Counting functions, 46

CPU parallelism, 282

Create method, 121

CreateText function, 67

Cross-platform solutions, 392

Currying, 579

Custom attributes, 495, 496

CustomContent, 366

Custom Control, 438440

CustomEquality and CustomComparison, 218

images D

Databases

advantages of, 345

closing connections and, 350

creating, 348

database engine and, 346, 347

DataContract serialization, 93

Data Definition Language (DDL), 347

Data Manipulation Language (DML), 347

Data structures

concrete, 38

delayed, 50

foundational, 30

F# program, 14

hash function, 91

immutable, 9, 31–33, 54

mutable, 32, 33, 54, 62–63, 7677

options, 33

Decimal type, 234

defaultArg functions, 121

Default keyword, 135

Delayed computations, 46, 78–79, 486

Delayed data structures, 50

Delegates, 100, 144

Delegation, 133

DependencyObject, 473

Deserialize function, 93

dictionariesENDRG, 62

Dictionary

hash-table structure, 60

key types, 60

KeyValuePair, 61

TryGetValue method, 6162

with compound keys, 62

Discriminated unions

as records, 86

discriminator, 84

.NET Library Design Guidelines and, 579

nonextensible modules, 86

pattern matching, 8485

recursive functions, 85

recursive references, 85

size function, 86

sizeOfTree, 85

‘T option type, 85

tree-like data structures, 85

Discriminator, 84

Dispose operation, 68

DivideByZeroException, 234

<div> tag, 368

DllImport custom attribute, 524

Docking control, 432

do expr constructs, 275

do! expr constructs, 275

Dot (.) notation, 83

Double buffering, 452

Downcast operator, 101102

Drawing namespace, 178

Dynamic Link Libraries (DLLs), 159

Dynamic lookups, 497

Dynamic memory, 515

images E

emptyLists generics, 108

Encoding/decoding

binary data , 176

unicode strings, 175

Enums, 145

Enum types, 100

Equality, hashing, and comparison

asserting using attributes, 218

constraints, 217, 218

customizing on a type, 219220

generic collection types, 221

generic operations, 217

ordered comparison, 218

suppressing on a type, 220

Equational reasoning, 572, 574

Error estimation, via quotations, 499

Euclid’s algorithm, 94, 97

Events, 151

as first-class values, 260

creating and publishing, 260262

creating WinForms, 259

from .NET libraries, 259260

Exception propagation, 273274

Exception-related language and library constructs, 66

Exception types, 100

Exhaustive patterns, 35

Explicit arguments, 107108

Explicit constructors, 117

Explicit factoring, 97

Extern keyword, 524

Extreme Optimization library, 245

images F

F#, 295, 296

background of, 2

web site for, 6

Facebook

Class function, 409

configuration, 409410

FB class, 409

IntelliFactory.WebSharper.Facebook namespace, 409

Main.fs, 407409

main HTML application

Boolean value, 415

Click event handler, 414

FB.Login and FB.Logout functions, 414

LI node, 415

Main.fs, 411414

Main.html, 410411

Mobile.Instance.ShowPageLoadingMsg, 414

updateStatus function, 414

Res.FacebookAPI resource, 409

status messages, 406

Visual Studio, 407

WebSharper documentation, 409

F# and .NET libraries

binary format, 504

C5 collection library, 509

COM components, 504

data structures, 508

Microsoft.FSharp.Collections, 508

System.Collections.Generic namespace, 509

DLLs, library constructs, 505

F# compiler, 504

interoperability, 512

COM (see Component Object Model (COM))

Common Language Runtime, 512514

memory management, 514516

types, 503

namespaces and, 507

.NET delegate type, 511

PowerCollections, 509

reflective techniques

general types, 510511

Microsoft.FSharp.Reflection, 511

schema compilation, 510

F# code

debugging

“abba” string, 544, 545

assertions, 549

attributes controlling program, 550

classes, 548

concurrent and graphical applications, 551553

ConditionalAttribute, 549

debuggable programs, 544

DebuggerDisplayAttribute, 550

isPalindrome function, 549

menu, 545

MyComplex record, 550, 551

palindrome string, 544

program state inspection, 544

recursion, 544

System.Diagnostics namespace, 548551

Visual Studio debugger (see Visual Studio debugger)

Watch view, 545

window, 545

WriteXXX methods, 549

packaging

application data, 542

command-line compiler, 538

conditional compilation, 538

data and configuration settings, 543

interactive scripts, 537538

optimization settings, 538

shared libraries, 539541

software entity, 541542

static linking, 541

XML documentation, 539

testing

Category and Culture attributes, 560

fixtures, 561

FsCheck, 558

goal, 557

Ignore and Explicit attributes, 560

.NET debugger, 557

nunit-console.exe, 562

NUnit tool, 558562

posTests and negTests functions, 559

setup and teardown methods, 561

test fixture, isPalindrome function, 558, 561

TestFixtureSetUp and TestFixtureTearDown attributes, 561

test suite, isPalindrome function, 558

unit tests, 559, 560

F# command-line compiler (fsc.exe), 154

F# compiler, 11, 12

File handling technique, 136

File.OpenText, 103

FindMinMax method, 443

FindName method, 470

F# Interactive, 7, 465

Alt+Enter shortcut, 553

compiles code, 555

data structures, 14

development and testing, 553

directives, 554

double semicolons (;;), 12

F# code, 11, 12

fsi.exe, 8

fsi object, 554

.NET Framework, 19

scripting, 537

showWordCount function, 8

splitAtSpaces function, 8, 11

val keyword, 8

Visual Studio, 8, 556

wordCount function, 8

Firebird database engine, 346

First-in/first-out (FIFO) collection, 63

Flexible type constraint, 104

F# libraries, 119

design compliance checks and, 568

functional programming design techniques, 571

.NET Library Design Guidelines and, 565, 568

vanilla .NET libraries, 566

Flickering, 452

FLinq, 340

float32 type, 234

Floating constraints, 109

Float operator, 235

Flowlets, 359, 387

F# operators

dynamic reflection operators, 497

quotations

error estimation, 499501

need for, 498

resolving reflected definitions, 501

Form, 2021

Format static method, 167

Formatting dates, 168

Formlets, 359

Android applications, 425

ASP.NET server control, 380381

ASP.NET server-side controls, 384

dependent, 387

Enhance.Many, 386387

Enhance.WithFormContainer function, 383

Formlet.Yield combinator, 381

helper function, 380

input field, 385

IntelliFactory.WebSharper.Formlet.Enhance, 381383

IntelliFactory.WebSharper.Formlet namespace, 379380

library features, 383

RunSnippet, 380

sitelet, 385

snippets, 384, 386

string-int pair, 386

text-box formlet, 379

validation error, 383

Validator.Is, 381

wrapper and render function, 380

Forward pipe (|>) operator, 581

F# PowerPack, 313

F# program

calling functions, 11

code documentation, 9

data structures, 14

F# Interactive (see F# Interactive)

imperative code, 1718

let keyword, 9

Lightweight Syntax, 1112

object-oriented libraries (see Object-oriented libraries)

properties and dot-notation, 1415

scope, 1214

string analysis, duplicate words, 7

tuples

arbitrary number, 16

fst and snd functions, 16

inferred types and computed values, 16

patterns, 16

showResults function, 17

showWordCount function, 17

type-checking error, 1617

values and objects, 17

wordCount function, 15

types, 1011

values and immutability, 9

F# quotations, 498

.fsi file extension, 155

Functional programming

conditionals, 28

currying and, 579

F# library design techniques, 571

function values. (see Function values)

and imperative programming, 49

memoization (see Memoization)

precomputation (see Precomputation)

lists (see Lists)

multiparadigm languages and, 565

numbers

arithmetic comparisons, 27

arithmetic conversions, 26

arithmetic operators, 26

binary operator, 26

overloaded operator, 26

type annotation, 26

types and literals, 25

options, 33

pattern matching (see Pattern matching)

recursive functions

alternatives, 29

control, 29

factorial coding, 29

HTML fetching, 29

List.length, 29

mutually, 30

nonrecursive implementation, 30

tail recursive, 30

well-founded, 30

strings, 27

types

definitions (see Type definitions)

generics (see Generics)

.NET types (see .NET types)

subtyping (see Subtyping)

type-inference (see Type inference)

with side effects

imperative programming and laziness, 78

mutable data structures seperation, 76

pure and side-effecting computations seperation, 76

recursion, 76

weak vs. strong side effects, 77

Functions

currying, 579

generic, 500

Function values

abstract control, 44

accumulators model, 47

actions model, 46

aggregate operators

Array.filter and List.map, 39

design pattern, 40

getStats function, 40

iteration, 44

pipeline operations, 40

anonymous, 39

binary operators model, 46

callbacks model, 46

concrete data structure, 38

counting functions model, 46

delayed computations model, 46

forward composition operator, 41

function fetch, 38

generators model, 46

input lists, 38

key functions model, 46

List.map, 38

literal list of URLs, 38

local functions, 42

object methods as first-class functions, 45

orderings model, 46

output lists, 38

partial application, 42

predicates model, 46

remap function, 45

sinks model, 46

statistical functions model, 46

transformations model, 46

FxCop, 566

images G

Garbage collection, 136, 515

g command-line flag, 161

Generators, 46

Generic algorithms

explicit arguments, 94

function parameters

concrete record type, 95

dictionaries of operations, 96

explicit factoring by functions, 97

hcfGeneric type, 96, 97

IDisposable interface, 97

implicit factoring by hierarchy, 97

object interface types, 96

type classes, 97

inlining, 97

Generic functions, 38, 500

Generic operators, 119

Generics

algorithms (see Generic algorithms)

F# list types, 87

functions

automatic generalization, 88

binary serialization, 92

boxing and unboxing, 91

dummy arguments, 108

generic comparison, 89

hashing, 90

pretty-printing, 91

List.map, 87

Generics

overloaded operators, 109

Set type, 87

type abbreviations, 87

type annotation, 88

type parameters, 88

type variables, 87, 88

GenericZero function, 98

getFirst, 88

GetResponse method, 22

GraphControl

AddSample method, 442, 443

configuration, 442

DataSamples class definition, 443

FindMinMax method, 443

FSharpChart, 442

Model-View-Controller paradigm, 443

plot samples, 441

PropertyGrid, 453

SplitContainer control, 453

style properties and controller

AxisColor property, 445

Model-View-Controller paradigm, 447

mouse-move events, 448

OnPaint drawing method, 445, 448

overridden vs delegation, 448

test application, 442

view

Background color property, 449

double buffering, 452

drawing, 449

OnPaint method, 449

paint method, 449

Graphics objects, 136

GUI

BackgroundWorker connection, 268

thread events code, 267

images H

Hardware design, 296

Hash function, 90

Haskell programming language and monads, 2, 479

hcfGeneric function, 98, 99

Heap allocated memory, 136

Hello World (sample) function, 523

Highest common factor (HCF), 94

HTML5 standards, 392

Hue saturation value (HSV), 455

images I

I command-line flag, 161

i command-line option, 154

IComparable interface, 130

IDisposable interface, 68, 97, 130

IEnumerable interface, 129

IEnumerator interface, 130

IEvent interface, 130

if/then/elif/else construct, 28

Immutability, 9, 27

Immutable data structures, 9, 32, 54

Immutable lists, 85

Immutable values, 9

Imperative programming, 33

arrays andENDRG, 60

arrays

generation and slices, 58

module, 57

.NET types, 58

one-dimensional, 56

primitive types, 58

reference types, 58

two-dimensional, 59

value types, 58

dictionaries andENDRG, 62

exceptions

catching, 64

categories, 64

failwith function, 63

function types, 63

GetResponse method, 63

new types, 65

System.Net.WebException, 63

try ... finally ... construct, 65

values, 63

and laziness, 78

for loops, 50

vs. functional programming, 49

and functional programming

memoization (see Memoization)

precomputation (see Precomputation)

with side effects, 75

I/O techniques

abstractions, 68

file-processing, 67

.NET I/O via streams, 67

ReadLines function, 67

System.Console, 69

WriteAllLines function, 66

loops, 50

mutable locals, 56

mutable records. (see Mutable records)

.NET collections

dictionaries (see Dictionary)

other mutable data structures, 62

resizeable arrays, 59

sequence loops, 51

while loops, 51

Implementation, 304

code, 580

inheritance, 134

delegation and, 133

.NET Library Design Guidelines and, 578, 579

Implicitarguments, 107

constructors, 116

factoring, 97

Indexer properties, 21, 118, 124

Inferred type parameters, 88

Inferred types, 115

Infixfunction, 119

operators, 26, 171

Inherit keyword, 130

Instance members, 15, 23

Integrating external data/services

language integrated OData

example, 335

handling pagination in OData, 339

query, 337

type provider, 336

language integrated SQL, 340

relational databases and ADO.NET

advantages of, 345

connecting to, 347

creating tables, 348

database engine and, 346

using stored procedures, 350

relational query operations

aggregation, 342

grouping, 344

inner queries, 343

joins, 344

nullables, 343

sorting, 342

REST requests

handling multiple pages, 334

JSON Format, 333

parsing XML/JSON data, 333

using WSDL services, 351

IntelliFactory.WebSharper.Android, 415

IntelliFactory.WebSharper.Android.Bluetooth, 416

IntelliFactory.WebSharper.Formlet namespace, 387

IntelliFactory.WebSharper.Formlets.JQueryMobile namespace, 425

IntelliFactory.WebSharper.Mobile, 415

IntelliFactory.WebSharper.Mobile.IAcceleration, 415

IntelliFactory.WebSharper.Mobile.ICamera, 416

IntelliFactory.WebSharper.Mobile.IGeolocator, 415

IntelliFactory.WebSharper.Mobile.ILog, 416

IntelliFactory.WebSharper.Sitelets, 372

IntelliFactory.WebSharper.Sitelets.Content module, 366

IntelliFactory.WebSharper.Web.Control, 362

Interface inheritance, 130

Interfaces

concrete types, 129

definition, 126, 127

ENDRG, 135

hierarchies of, 130

implementing, 127, 129

from .NET libraries, 129

partial implementations for, 131, 135

Internal accessibility annotation, 150, 152

Internal message protocols, 286

Internet Explorer Web Browser COM component, 518

InteropServices namespace, 524

int operator, 235

int type, 234

I/O bound application, 275

iOS devices

AddEventListener, 405

<canvas> element, 404

CDATA block, 400

Client.MyControl, 404

extra.files, 399

gesturechange event, 405

image viewer application, 398

index.html, 404

IntelliFactory.WebSharper.Mobile.Events class, 405

jQuery Mobile extensions, 404

Main.fs, 400

Main.html, 399

mobile events and features, 405

MyControl, 404

MySitelet, 404

OnAfterRender event, 404

OnLoad event, 404

scale and rotation, 405

virtual mouse events, 404

VMouseDown event, 404

Item property, 118, 124

Iterative worker, 264

ITextOutputSink, 131

images J

Java Native Interface (JNI), 524

JavaScript.SetInterval function, 425

JpegBitmapDecoder, 474

JpegBitmapEncoder, 474

JSON format, 333

Just-In-Time (JIT) compiler, 513

images K

Key functions, 46

images L

Lambda expressions and F# quotations, 498

Language integrated OData

example, 335

handling pagination in OData, 339

query, 337

type provider, 336

Language integrated SQL, 340

Language-oriented programming

quotations and, 498

reflection and, 492

workflows and, 478

relational databases and, 347

Last-in/first-out (LIFO) collection, 62

Lazy lists, 182

Lazy sequences, 192, 349

Leaf rewriting (mapping), 205

Left-to-right, leftmost derivation (LL parsers), 183

Let bindings

resolving definitions for, 501

workflows and, 482

let pat = expr constructs, 275

let! pat = expr constructs, 275

Lexers, language oriented programming, 477

Line-based input processing, 169

LINQ (Language Integrated Query), ToSql queries, 340

Lists

and arrays, 195

cons operator, 31

foundational data structures, 30

function values, 32

input, 38

language constructs and operators, 30

List.map, 38

literal, 38

module, 31

@ operations, 31

output, 38

primes type and value, 31

processing, 223

values, 30

vs. resizable arrays, 59

Literal byte arrays, 164

loadXamlWindow, 472

Local functions, 42

Local variable, 9

Lock function, 292

LoginRedirect, 371

images M

MailboxProcessor

asynchronous web crawling, 287

implementing counter, 283

member types, 286

object wrapping, 284, 285, 286

scanning mailboxes, 286

state machines, 284

Mandelbrot Viewer creation

application plumbing, 460

computing Mandelbrot, 454

delegation programming style, 454

fractals, 454

setting colors, 455

visualization application, 457

Map and filter operations, 196

mapFirst function, 107

Markup syntax, 468

Marshal class, 521

MatchCollection, 51

MatchFailureException, 36

Measure attribute, 250

membersENDRG, 114

Memoization

and caching, 75

fibFast function, 72, 74

fibNotFast function, 73

function, 72

lazy values, 74

lookaside table, 71

lookup and a discard method, 73

mutable internal tables, 74

service, 73

well-known Fibonacci function, 71

Memory model, 292

Message passing concurrency, 282

Message processing and state machines, 284

Metadata, 513

<meta> tag, 368

Method overloading, 121

Methods, .NET Library Design Guidelines and, 21, 578

Microsoft

FxCop, 566

Microsoft.FSharp.Reflection namespace, 511

Mimer SQL, 346

Mobile.VMouseEventArgs, 405

Mobile web applications

Android Applications (see WebSharper, Android applications)

feature detection and polyfilling

Boolean value, 393

HasJs.Has, 394

HTML5 support, 393

JavaScript snippet, 393

libraries, 394

Modernizr, 393

WebSharper, 395

iOS devices. (see iOS devices)

mobile capabilities, 396

mobile frameworks, 396

serving mobile content, 397

social networking (see Facebook)

touch events, 395

vs. native mobile applications, 391

WebSharper mobile, 415

Model-View-Controller design pattern, 441

Monads, 479

Monoids, 480

Multiparadigm languages, 565, 574

Mutable data structures, 33, 54, 62, 76

MutablePair class, 293

Mutable records

aliasing, 54

event counter, 52

hidden mutable data, 55

long page counter, 52

mutable values, 52

mutation and identity, 55

<- operator, 52

reference cells, 53

Mutable reference cells, 53

Mutable state, 122

Mutually recursive functions, 30

MyExternalResource, 388

MySQL, 346

images N

Named arguments, 120

Naming conventions, 576

interfaces and, 126

object interface types and, 130

per .NET Library Design Guidelines, 574

Nativeint type, 234

Negation normal form (NNF), 215

N escape character, 165

.NET asynchronous operations, 279

.NET CLR, 258

.NET collections, 91

.NET event handlers, 259

NET interoperability, 193

NET libraries

vanilla, 566

.NET libraries. See F# and .NET libraries

binary serialization, 92

imperative code, 18

object-oriented libraries, 18

text.Split, 19

XML, 23

NET Library Design Guidelines, 565

applying to F# programming, 574

checking for compliance with, 568

.NET methods, 45, 51

.NET proxies, 389

.NET shared-memory concurrency primitives, 294

.NET thread pool, 273

NET ToString() method, 91

.NET types

attribute types, 100

delegate types, 100

enum types, 100

exception types, 100

reference types, 99

value types, 99

Network connections, 136

NoComparison and NoEquality, 218

Nonexhaustive matches, 36

Non-numeric types, 25, 233

Northwnd sample database, 340

Not a Number (NaN) values, 235

Null values, 145

numDups, 8

Numeric data, 231

built-in aggregation operators

advantage, 239

complex relationship, 241

computation, 237

counting and categorization, 239

KMeans culstering algorithm, 242

numeric code writing, 240

Seq.maxBy operator, 238

Seq.minBy operator, 239

Seq.sumBy operator, 238

unitized/generic code, 241

charting with FSharpChart, 231, 232, 233

.NET math library

and frameworks, 245characteristics, 244

eigenvalues and eigenvectors of matrix, 250

histograms and distributions, 246

inverse matrix, 249

matrices and vectors, 248

matrix decomposition, 249

statistical function, 245

types and literals

arithmetic conversion, 235

arithmetic operators, 234

bitwise operations, 236

bool and unit, 233, 234

checked arithmetic, 234

comparison operators, 235

overloaded Math functions, 236

units of measure

annotations, 250, 251

applications, 250

apply and removal of units, 254

attribute, 250

computation, 250

data sequence, 253

generic algorithm, 251

KMeans algorithm, 255

limitations, 254

linear function, 252

numerical-integration techniques, 251

parameters, 253

variance function, 252

vector type, 253, 254

Numeric types, 25, 26

numWords, 8

images O

Object expressions, formatting, 581

Object identity, 9

Object interface types, design guidelines, , 96, 579

object interface types. See Interfaces , 126

Object Linking and Embedding (OLE) technology, 516

Object-oriented libraries

fetching Web Page, 22

.NET libraries, 18

new keyword, setting properties, 20

open keyword, namespaces and modules, 19

Object-oriented (OO) programming, 225

functional programming and, 565

library design and, 571, 573

.NET Library Design Guidelines and, 578

Object programming

classes

construction sequence, 116

constructors, 116

explicit constructors, 117 generic instantiation, 117

inferred type, 115

length precomputation, 114, 115

Scale method, 116

static bindings, 117

symmetry, 114

cleanup resource

IDisposable, 136

lexical scope, 135

operating-system resources, 135

F# object and .NET types

delegates, 144

delimitation, 143

enums, 145

null values, 145

structs, 144

modules extension

code organization, 143

mutable state

auto-property, 125

complexity, 124

currDX and currDY, 123

definition, 122

indexer property, 124

inferred signature type, 123, 124

optional property settings, 124, 125

Vector2D type, 122

notational convenience

dot notation, 117

indexers property, 118

method overloading, 121, 122

named arguments, 120, 121

optional arguments, 120, 121

overloaded properties, 118, 119

object interface types

abstract types, 126

concrete types, 129

definition, 127

hierarchies of, 130, 131

implementation variations, 126

IShape, 126, 127

from .NET libraries, 129, 130

object expression, 127, 128

objects and members, general rules, 114

partial implementation

abstract members, 133

concrete types, 133

creation, 131

delegation, 133, 134

function parameter, 131, 132

implementation inheritance, 134

object expression, 131, 132

objects, 135

Observables, 290

OCaml

library design and, 566

underscore (_) and, 576

OCaml programming language, 2

O command-line flag, 161

Offline sitelets, 364

On-demand computation, 206

Online sitelets, 365

OnPaintBackground method, 436

OpenText function, 68

Operator overloading, 235

Operators, 290

infix, 171

recommendations for using, 581

Optional arguments, 120

Optional property settings, 124

Option values, .NET Library Design Guidelines and, 577

Oracle database engine, 346

Out parameter, 61

Outscope values, 13

Override keyword, 135

Overriding methods, 447

images P

Packaging code, abbreviations, 153

Padding, 516, 526

PageContent, 366

Pagelets, 359, 360

Pages.ProtectedPage, 371

Parallel programs, 258

Parser combinators, language-oriented programming and, 477, 186

Partial and parameterized active patterns, 214

Pattern matching, 21, 28, 286

form patterns, 37

guarding rules and combining patterns, 36

inferred type function, 34

isLikelySecretAgent, 34

keyword, 34

list values, 34

match ... with ... construct, 34

option, 33, 35

primes, 35

rule, 34

strings and integers, 34

structured values, 35

subtyping, 102

tuple, 34

Performance guidelines (see Guidelines)

Persistent data structure. (see Imutable data structures)

Pickering, Robert, 478

Pinning, 527

Pipeline operations, 40, 581

Pipelining, 193

Placeholders, 367

Platform Invoke

calling conventions

activation record, 522

fcall convention, 523

memory leak, 523

stdcall and cdecl convention, 523

thread stack, 523

C data structures mapping

definition, 525

StructLayout custom attribute, 525

SumC prototype, 526

definition, 522

DllImport custom attribute, 524

execute native code, 524

extern keyword, 524

function pointers, 530

functions, 522

Hello World (sample) function, 523, 524

interopServices namespace, 524

Java Native Interface, 524

marshalling parameters

function pointers, 526

native code, 526

native functions, 527

padding, 526

strings, 526

ZeroC function, 526, 527

marshalling strings

ANSI C strings, 529

C function, 528

default conversions, 528

F# PInvoke prototype, 529

sayhello function, 529

string buffer, 529

System.Text.StringBuilder object, 529

memory mapping, 531, 533, 534

parameter passing, 525

Sum function, 524

wrapper generation limitations, 534, 535

Polymorphism, 128

PostAndReply, 286

PostgreSQL, 346

PowerCollections library, 509

precomputation, 496

Precomputation

and objects, 70

and partial application, 69

Primary constructors, 116, 124

Printf module and function, 17, 165

Private accessibility annotation, 150

probabilistic workflows, 487

Procedural programming, library design and, 571

Progressive enhancement, 392

rProperties, design duidelines

PropertyGrid, 453

Propositional logic

AndL function, 301

arrays of propositions, 301

BDD

circuit verification, 307

Equiv, 306

language representation techniques, 304

logical rules, 306

mkAnd operation, 306

pretty-printer installation, 306

Prop representation, 306, 307

ToString member, 306

circuit components, code, 300

circuits property, checking, 303

formulae evaluation, 298

halfAdder, propositional formula, 302

hardware circuits, 300

minimalistic representation, 297

N-bit adder, 301

primitive propositions, 297

Prop formula, 297

QBF, 296

truth tables, 299

twoBitAdder, 302

Public accessibility annotation, 150, 151, 152

images Q

Qualified names, 152

Quantified Boolean formulae (QBF), 296

Queries. See also Relational query operations

Query, definition, 337

Quotations

example of, 499

rationale for using, 498

images R

RandomTicker, 260

Range expressions, 190

r command-line flag, 161

Reactive programs, 258

ReadAllLines function, 67

ReadAllText function, 67

ReaderWriterLock, 293

readValue function, 92

Records

cloning, 84

discriminated unions, 86

F# Interactive, 83

heterogeneous results, 82

labels, 82

.NET Library Design Guidelines and, 579

non-unique field names, 83

stats, 82

type annotation, 82

type.field syntax, 82

Records, relational databases and, 348

Recursive functions

alternatives, 29

control, 29

discriminated unions, 85

factorial coding, 29

HTML fetching, 29

List.length, 29

mutually, 30

nonrecursive implementation, 30

tail recursive, 30

well-founded, 30

Recursive workflow expressions, 492

redraw() function, 404

Reference types, 99

Reflection

types and, 493

library, 496

reflection, 492

Regular expressions, 163

Relational databases and language

Relational databases and ADO.NET

advantages of, 345

connecting to conn, 347

creating, 348

creating tables, 348

database engine and, 346

using stored procedures, 350

Relational query operations

aggregation, 342

grouping, 344

inner queries, 343

joins, 344

nullables, 343

sorting, 342

RequestGate, 289

Require attribute, 388

R escape character, 165

Resgen.exe tool, 543

ResizeArray module, 60

Resource lifetime management, 274

Resources, combine with workflows

Resources.BaseResource, 388

Resources for further reading, mreasure, 255

Responsive web design, 392REST requests

handling multiple pages, 334

JSON Format, 333

parsing XML/JSON data, 333

return expr constructs, 275

return! expr constructs, 275

RichTextBox control, 21

Runtime callable wrapper (RCW), 518

Runtime type, 101

images S

Samples

error estimation, quotations and, 499

workflows, 480

sbyte operator, 235

sbyte type, 233

Schemas, type reflection, 493

Scope, 12

Sequence expressions and workflows, 478

Sequences

aggregate operators, 191

compatible types, 192

expressions, 58, 60, 349

finding elements and indexes, 199

folding sequences, 201

grouping and indexing, 200

iteration, 191

lazy sequences, 192

map and filter operations, 196

selecting multiple elements, 198

truncate and sort operations, 197

using range expressions, 190

using sequence expressions

additional logic, 194

cleaning up, 202

computation expressions, 194

expressing operations, 203

generating lists and arrays, 195

Serialize function, 93

Serializer, 93, 94

Server-side functionality, 363

Set.ofList function, 14

setTextOfControl function, 103

settleDelta() function, 404

Shared-memory concurrency, 282

concurrency primitives, 294

explicit thread creation, 291

race conditions and .NET memory model, 291

using locks, 292

using ReaderWriterLock, 293

showResults function, 17

ShowVisualTree function, 473

showWordCount function, 17

Side effects and workflows, 485

Signature types/signature files, and guidelines, 578

Silverlight, 465

Sinks, 46

Sitelet.Filter value, 371

Sitelet.Infer constructor, 370

Sitelets

Action.MyPage action, 364

Action type, 364

client-side controls, 368

construction, 369

dynamic templates, 367

non-GET HTTP commands

basic menu and order creation form, 376

conceptual mapping, 373

Create Order and List Orders pages, 379

CreateOrderForm, 374

formlet, 374

helper functions, 374

JSON representation, 378, 379

ListOrders, 374

Main.fs file, 373, 374

Main.html file, 373, 374

order attributes, 373

order storage, 373

POST and PUT requests, 378

response content functions, 377

specific order retrieval, 376

online vs. offline, 364

routers and controllers, 372

serving content, 365

single-page sitelet, 363

Sitelets.Website attribute, 364

Sitelet.Sum combinator, 372

Slice notation, 58

Smart web applications

Ajax rich client applications

development methods, 358

WebSharper (see WebSharper)

web server

arbitrary TCP server, 356

asynchronous task, 356

cloud-computing solutions, 358

coding in F#, 354

GET request, 356

HTTP commands, 353

quote server, 356

Regex1, 356

scaling, 358

SSL server, 357

TCP socket connection, 355

splitAtSpaces function, 11

SplitContainer control, 453

sprintf function, 165

SQLite, 346

SQL Server Express, 346, 347

Stack- and heap-allocated memory, 222

Stack, resources, 136

Static members, 15, 23

Static memory, 514

Statistical functions, 46

stdcall calling convention, 530

stored procedures, 350

Stream, 69

StreamReader, 68, 78

StreamWriter, 67

StringBuilder, 67

String placeholder, 368

StringReader, 68

Strings

formatting, 163, 167

parsing, 170

printfn function and, 165

regular expressions and, 171

sprintf function and, 165

unicode encoding/decoding and, 175

StringWriter, 67

StructLayout custom attribute, 525

Structs, 144

Structural comparison, 89

StructuralEquality and StructuralComparison, 218

Structural formatting, 167

Structural hashing, 62

Structured data

active patterns (see Active patterns)

equality, hashing, and comparison. (see Equality, hashing, and comparison)

Structured Query Language (SQL), 347

Subarrays, 58

Submodules, 153

Subtyping

automatic upcasting, 102

dynamic casting, 101

flexible types, 104

.NET types, 99

pattern matching, 102

static casting, 101

SWIG wrapper generator, 535

Sybase iAnywhere, 346

Symbolic differentiation

algebraic expression

abstract syntax representation, 313, 314

ExprUtil.fs, 313, 320

main Expr type, 313

parsing, 315

simplifications, 317

StarNeeded member, 315

VisualExpr.fs, 313

Visual Studio 2012, 313

expression rendering

code, 326

expressions and sizes, 323

rendering options, 320

RenderOptions type, 320

visual elements and sizes, 321

VisualExpr, 323

local simplifications, 312

simple algebraic expressions modeling, 310

user interface client, 327

visual application, 310

Symbolic programming. See Propositional logic

Synchronization context, 268

Syntax member, object expressions and, 581

Syntax trees, 228

System namespace

core types, 508

supervising and program execution, 509

useful services, 508

System.Net library, 22

System.Net.WebRequest, 22

System.Object.ReferenceEquals function, 55

System.Reflection namespace, 493

System.Text.RegularExpressions, 171

System.Text.RegularExpressions.Regex.Matches, 51

System.Threading.AutoResetEvent, 294

System.Threading.Interlocked, 294

System.Threading.ManualResetEvent, 294

System.Threading.Mutex, 294

System.Threading.Semaphore, 294

System.Threading.WaitHandle, 294

System.Windows.Forms.Form, 20

images T

Tables, relational databases and, 348

Tail calls and recursive programming

and list processing, 223

object-oriented programming, 225

processing syntax trees, 228

processing unbalanced trees, 226

simple tail-recursive function, 222, 223

stack- and heap-allocated memory, 222

using continuations, 227

telnet.exe, 419

Text label, 20

TextOutputSink object, 133

TextReader, 68

text.Split, 19

Textual data

binary parsing and formatting

advantages, 184, 185

combinator-based pickling, 186

data aggregation, 185

data reliability, 183

marshalling, 183

picklers and unpicklers, 183

primitive read/write functions, 184

concrete type. (see Concrete language format)

data format

ASCII characters, 164

building strings, 163

code, printf style, 166

escape characters, nonverbatim strings, 165

generic structural formatting, 167

.NET formatting, 167

%O/%A pattern, 166

printfn and sprintf functions, 165

printfn module, 165

string and character laterals, 164

triple-quote string laterals, 164

parsing strings

basic value, 168

encoding and decoding. See Encoding/decoding

line-based input processing, 169, 170

regular expressions, 170

System.Text.RegularExpressions, 171, 172, 173, 174

recursive descent parsing

information extraction, 180

lazy lists generation, 182

LL parsers, 183

polynomials, 182

symbolic differentiation, 180

tokenizer for polynomials, 181

TextureBrush, 435

TextWriter, 68, 69

Thread hopping, 272

Threads, 258

Top-down rewriting, 205

Top-level members, resolving, 501

TopMost label, 20

Transact-SQL (T-SQL), 347

Transformations, 572

TRANSFORM_CALLBACK type, 530

Transformers model, 46

Truncate and sort operations, 197

TryGetValue method, 61

T-SQL (Transact-SQL), 347

Tuples

arbitrary number, 16

fst and snd functions, 16

hash fucniton, 91

inferred types and computed values, 16

.NET Library Design Guidelines and, 580

patterns, 16

showResults function, 17

showWordCount function, 17

type-checking error, 16

values and objects, 17

wordCount function, 15

Two-dimensional arrays, 59

Type abbreviations, 81, 153

Type annotations, 15, 88, 105

Type classes, 97

Type constraint, 92, 105

Type constructors, 10

Type definitions

discriminated unions (see Discriminated Unions)

multiple types, 87

record (see Records)

type abbreviations, 81

Type function, 108

Type inference, 10, 11, 41, 45, 193

explicit factoring, 97

generic functions, 88

subtyping, 100

troubleshooting

generic overloaded operators, 109

type annotations, 105

value restriction. (see Value restriction)

visual editing environment, 105

type classes, 97

Type of operator, 493

Type parameters, 38, 92

Type PingPong, 106

Type provider, 336

Types

language-oriented programming and, 477, 478

.NET Library Design Guidelines and, 578

partially implemented, 135

reflection and, 493

Type signatures, 89, 90

Type StreamReader, 103

Type-test patterns, 64, 102

Type TextReader, 103

Type TimeSpan, 44

Type variable, 45

images U

uint16 operator, 235

uint16 type, 233

uint32 operator, 235

uint32type, 234

uint64 operator, 235

uint64 type, 234

Unativeint type, 234

Unbox function, 92

binary serialization, 92, 93

dynamic casting, 101

.NET types, 99

Underscore (_), 576

Ungeneralized type variables, 106

UNNNNNNNN escape character, 165

Upcast operator, 101

urlCollector, 289

use pat = expr constructs, 275

UserControl class, 438

Utils.SimpleContent function, 369

images V

Value restriction

automatic generalization, 106

definition, 106

empty lists, 106

explicit type arguments, 108

generic functions

dummy arguments, 108

explicit arguments, 107

nongeneric constrain values, 107

Values, 21

types, 99

.NET Library Design Guidelines and, 577

vanilla .NET libraries, 566

Verbatim strings, 164, 172

VerifyUser, 371

Visible label, 20

Visualization and Graphical User Interfaces

control

anatomy of, 441

docking and anchoring, 432

Dock property, 430

fsi.exe., 431

layout, 432

placing controls, 429

registering controls, 429

single thread apartment model, 429

STAThread, 429

status bar, 430

Visual designers, 432

Web browser application, 430

WebBrowser control, 431

Windows Forms, 431

creation (see Mandelbrot Viewer creation)

drawing applications

Bézier curve, 434

brushes and pens, 435

canonical splines, 434

control point, 436

curves application, 436

movingPoint variable, 436

OnPaintBackground method, 436

paint-based model, 434

window, 434

graphical applications, 428

Hello, World! application, 427

sensor samples. See GraphControl

WPF (see Windows Presentation Foundation (WPF))

Visual Studio, 23, 350

Visual Studio debugger

debugging session, 545

features, 546

Visual Studio’s COM automation model, 521

VSLab Viewlets, 440

images W

WebRequest object, 22

WebSharper

Android applications

Android emulator, 417

ApplicationControl server control, 425

Client.BingMapsKey, 424

Client module, 424

Controls.Password function, 425

Controls.TextField function, 425

device configuration, 420

Enhance.WithSubmitButton function, 425

formlet code, 425

formlets, 417

installation and set up, 418

Main.fs, 422

Main.html, 421

MapOptions, 425

SDK documentation, 419

SDK Manager, 418, 419

setMap, 425

ShowMap() function, 425

tools, 419

updateLocation, 425

Visual Studio template, 420

ASP.NET-compatible server-side application, 359

automated resource tracking and handling, 387

documentation, 359

feature detection and polyfilling, 395

flowlets, 359, 387

formlets (seeFormlets)

mobile, 415

.NET proxies, 389

pagelets, 359, 360

Rich Internet Applications (RIAs), 360

server code, 362

sitelets (see Sitelets)

third-party JavaScript libraries, 388

Visual Studio 2010, 360

WebSharper script manager control, 362

Well-founded recursion, 30

Whitespace, regular expression and, 172

Wildcard patterns, 34, 36

Windows Forms

articulated frameworks, 429

brushes and pens, 435

COM components, 429

coordinate transformation, 449

DataSamples, 445

event loop, 428

F# Interactive, 466

fsi.exe, 429

OnPaintBackground method, 436

System.Windows.Application class, 466

User controls, 438

VSLab, 440

WPF’s layout model, 466

Windows Presentation Foundation (WPF)

bitmaps and images, 474

controls

ButtonChrome node, 473

data-binding expression, 474

DependencyProperty class, 473

FindName method, 472

loadXamlWindow, 472

logical tree, 472

nested controls, 472

opaque, 471

ShowVisualTree function, 473

TextBox implementers, 473

Text property, 473

visual tree, 472

definition, 465

dependency properties and animations, 466

drawing

application, 467

markup syntax, 468

window’s visual tree, 468

XAML (see XAML)

event loop, 465

FSharpx.TypeProviders package, 465

layout model, 466

.NET framework, 465

paint-event-based paradigm, 467

retention-based, device-independent rendering, 466

Silverlight, 465

toolkit model, 467

Turbo Pascal, 466

Win32 and GDI rastering engine, 476

window from F# Interactive, 465

XML-based composition language, 466

Window.xaml code, 469

wordCount function

calling functions, 11

code documentation, 9

F# Interactive, 8

Length and Count, 14

let keyword, 9

lightweight syntax, 11, 12

scope, 12

tuple, 15

type, 10

workflows

examples of, 480

workflows (computation expressions), 194

builder for, 478, 483, 488

combining with resources, 492

constructs, 479

how they work, 478

key uses of, 478

probabilisticBEGINRG, 487

probabilisticENDRG, 491

recursive workflow expressions and, 492

resources cleanup and , 492

side effects and, 485

success/failure and, 480

terminology and, 480

with custom query operators, 486

workflowsENDRG, 492

writeCharFunction parameter, 131

WriteLine functions, 167

writeValue function, 92

WSDL services, 351

images X, Y

XAML

ASP.NET files, 468

BAML, 468

Blend and Visual Studio, 465

business logic, 469

coordinate system, 470

C# source files, 468

FindName method, 470

F# project system, 468

FSharpx type, 469

F# source code, 465

graphical elements, 469

Microsoft Expression Blend, 469

source-code generation, 468

transformed elements composition, 470

Visual Studio, 469

visual tree, 469

Window class, 468

window definition, 468

WYSIWYG editor, 469

XML, 23

language-oriented programming and, 477

XmlAttribute type, 177

XmlDocument type, 177

Xml namespace, 176

XmlNode type, 177

XmlReader type, 177

XmlWriter type, 177

XPath, 180

images Z

zeroCreate function, 146

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.106.237