NetStudent.cz - články v kategorii Obecná .NET témata http://www.netstudent.cz/Articles/?tag=obecna-net-temata&author= Nejnovější články na webu NetStudent.cz v kategorii Obecná .NET témata Wed, 19 Jan 2025 11:23:51 +0100 cbea7651-15b2-438c-9b58-26394a32980c http://tomasp.net/rss.xml Tomáš Petříček The RSS feed has been moved The new feed is available at http://tomasp.net/rss.xml Mon, 26 Aug 2024 20:54:46 +0200 2c49cc7a-5b7f-46aa-ae34-4a21a218c739 http://tomasp.net/blog/types-and-math.aspx Tomáš Petříček Power of mathematics: Reasoning about functional types One of the most amazing aspects of mathematics is that it applies to such a wide range of areas. The same mathematical rules can be applied to completely different objects (say, forces in physics or markets in economics) and they work exactly the same way. In this article, we'll look at one such fascinating use of mathematics - we'll use elementary school algebra to reason about functional data types. In functional programming, the best way to start solving a problem is to think about the data types that are needed to represent the data that you will be working with. This gives you a simple starting point and a great tool to communicate and develop your ideas. I call this approach Type-First Development and I wrote about it earlier, so I won't repeat that here. The two most elementary types in functional languages are tuples (also called pairs or product types) and discriminated unions (also called algebraic data types, case classes or sum types). It turns out that these two types are closely related to multiplication and addition in algebra... Tue, 14 May 2024 17:54:46 +0200 cc6da545-7a3a-49b0-9b68-f960aa2f141d http://tomasp.net/blog/csharp-async-gotchas.aspx Tomáš Petříček Async in C# and F#: Asynchronous gotchas in C# Back in February, I attended the annual MVP summit - an event organized by Microsoft for MVPs. I used that opportunity to also visit Boston and New York and do two F# talks and to record a Channel9 lecutre about type providers [5]. Despite all the other activities (often involving pubs, other F# people and long sleeping in the mornings), I also managed to come to some talks! One (non-NDA) talk was the Async Clinic [1] talk about the new async and await keywords in C# 5.0. Lucian and Stephen talked about common problems that C# developers face when writing asynchronous programs. In this blog post, I'll look at some of the problems from the F# perspective. The talk was quite lively, and someone recorded the reaction of the F# part of the audience as follows... Mon, 15 Apr 2024 04:00:03 +0200 9f84d570-218c-485e-9231-b393b5867a61 http://tomasp.net/blog/fsharp-data.aspx Tomáš Petříček F# Data: New type provider library When F# 3.0 type providers were still in beta version, I wrote a couple of type providers as examples for talks. These included the WorldBank type provider (now available on Try F#) and also type provider for XML that infered the structure from sample. For some time, these were hosted as part of FSharpX and the authors of FSharpX also added a number of great features. When I found some more time earlier this year, I decided to start a new library that would be fully focused on data access in F# and on type providers and I started working on F# Data. The library has now reached a stable state and Steffen also announced that the document type providers (JSON, XML and CSV) are not going to be available in FSharpX since the next version. This means that if you're interested in accessing data using F# type providers, you should now go to F# Data. Here are the most important links: F# Data source code on GitHub F# Data documentation & tutorials F# Data on NuGet Before looking at the details, I would like to thank to Gustavo Guerra who made some amazing contributions to the library! (More contributors are always welcome, so continue reading if you're interested...) Thu, 28 Mar 2025 03:23:41 +0100 5726f549-aa50-4b0c-b8bf-489861ff1ab6 http://dajbych.net/overview-of-the-net-framework Václav Dajbych Overview of the .NET Framework The .NET is a very large framework and sometimes is hard to decide whether to code something or use an existing component of the framework. Sometimes is faster to code, but when production workload and reliability comes into play, the perspective is different. An overview of what .NET offers is a fundamental knowledge. It is hard to keep in track because .NET evolves very fast. This article discusses essentials which is the .NET Framework built from. Sat, 16 Feb 2025 00:00:00 +0100 1461c46e-18e0-40dd-97bb-c271689ab558 http://tomasp.net/blog/events-winter-2013.aspx Tomáš Petříček Upcoming F# talks and trainings (London, NYC & Boston) After a few years, I finally managed to find the time to attend the MVP Summit this year. The Summit is an annual event where people who are active in Microsoft technical communities come to the Microsoft headquarters to learn about new things (and, of course, tell them how they should be doing their job :-)). The Summit is a great place to meet interesting people (so if you're reading this and will be there, definitely get in touch!) The good news - for those interested in F# - is that I'll be doing two F# talks on the way and we also have a new F# course scheduled for later in the year. Continue reading to learn more! Thu, 07 Feb 2025 23:00:22 +0100 b7f00f03-85bd-4f4f-b44f-ec582f93a947 http://tomasp.net/blog/fsharp-literate-programming.aspx Tomáš Petříček Announcing: Literate programming tools for F# For some time now, I've been writing my F# blog posts (and other F# articles published elsewhere) by combining F# code snippets and Markdown formatting. In fact, I even wrote a Markdown parser in F# so that I can post-process documents (to generate references etc). You can read about the Markdown parser in an upcoming F# Deep Dives book - currently, it is available as a free chapter! During the Christmas break, I finally found enough time to clean-up the code I was using and package it properly into a documented library that is easy to install and use. Here are the most important links: F# Formatting home page F# Formatting source code on GitHub F# Formatting package on NuGet To learn more about the tool and how to use it, continue reading! Tue, 22 Jan 2025 17:35:36 +0100 77884a06-8253-40e5-b7af-24fe99f29aaa http://blog.vjirovsky.cz/pouziti-sqlite-ve-winrt/?utm_source=netstudent&utm_medium=article&utm_campaign=sqlite Vašek Jirovský Použití SQLite ve WinRT Protože ve WinRT není zabudovaná databáze jako SQL CE, jednou z mála použitelných je SQLite. Při použití SQLite s nejrozšířenější knihovnou sqlite-net v WinRT aplikaci v ČR podmínkách můžete narazit. Tue, 01 Jan 2025 00:00:00 +0100 71524ed0-d0dc-461b-bcc8-98ffe5a77db5 http://tomasp.net/blog/tree-zipper-query.aspx Tomáš Petříček Processing trees with F# zipper computation One of the less frequently advertised new features in F# 3.0 is the query syntax. It is an extension that makes it possible to add custom operations in an F# computation expression. The standard query { .. } computation uses this to define operations such as sorting (sortBy and sortByDescending) or operations for taking and skipping elements (take, takeWhile, ...). For example, you can write: 1: query { forxin1..10do2: take33: sortByDescendingx }In this article I'll use the same notation for processing trees using the zipper pattern. I'll show how to define a computation that allows you to traverse a tree and perform transformations on (parts) of the tree. For example, we'll be able to say "Go to the left sub-tree, multiply all values by 2. Then go back and to the right sub-tree and divide all values by 2" as follows: 1: tree { forxinsampledo2: left3: map (x*2) 4: up5: right6: map (x/2) 7: top }This example behaves quite differently to the usual query computation. It mostly relies on custom operations like left, right and up that allow us to navigate through a tree (descend along the left or right sub-tree, go back to the parent node). The only operation that does something is the map operation which transforms the current sub-tree. This was just a brief introduction to what is possible, so let's take a detailed look at how this works... val query : Linq.QueryBuilder Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.query val x : int custom operation: take (int) Calls Linq.QueryBuilder.Take custom operation: sortByDescending ('Key) Calls Linq.QueryBuilder.SortByDescending type Tree<'T> = | Node of Tree<'T> * Tree<'T> | Leaf of 'T override ToString : unit -> string Full name: Tree-zipper-query.Tree<_> union case Tree.Node: Tree<'T> * Tree<'T> -> Tree<'T> union case Tree.Leaf: 'T -> Tree<'T> val x : Tree<'T> override Tree.ToString : unit -> string Full name: Tree-zipper-query.Tree`1.ToString match x with | Node(l, r) -> sprintf "(%O, %O)" l r | Leaf v -> sprintf "%O" v type Path<'T> = | Top | Left of Path<'T> * Tree<'T> | Right of Path<'T> * Tree<'T> override ToString : unit -> string Full name: Tree-zipper-query.Path<_> union case Path.Top: Path<'T> union case Path.Left: Path<'T> * Tree<'T> -> Path<'T> union case Path.Right: Path<'T> * Tree<'T> -> Path<'T> val x : Path<'T> override Path.ToString : unit -> string Full name: Tree-zipper-query.Path`1.ToString match x with | Top -> "T" | Left(p, t) -> sprintf "L(%O, %O)" p t | Right(p, t) -> sprintf "R(%O, %O)" p t type TreeZipper<'T> = | TZ of Tree<'T> * Path<'T> override ToString : unit -> string Full name: Tree-zipper-query.TreeZipper<_> union case TreeZipper.TZ: Tree<'T> * Path<'T> -> TreeZipper<'T> val x : TreeZipper<'T> override TreeZipper.ToString : unit -> string Full name: Tree-zipper-query.TreeZipper`1.ToString let (TZ(t, p)) = x in sprintf "%O [%O]" t p val left : _arg1:TreeZipper<'a> -> TreeZipper<'a> Full name: Tree-zipper-query.left Navigates to the left sub-tree val failwith : message:string -> 'T Full name: Microsoft.FSharp.Core.Operators.failwith val l : Tree<'a> val r : Tree<'a> val p : Path<'a> val right : _arg1:TreeZipper<'a> -> TreeZipper<'a> Full name: Tree-zipper-query.right Navigates to the right sub-tree val current : _arg1:TreeZipper<'a> -> 'a Full name: Tree-zipper-query.current Gets the value at the current position val x : 'a val branches : Tree<int> Full name: Tree-zipper-query.branches val sample : TreeZipper<int> Full name: Tree-zipper-query.sample val printfn : format:Printf.TextWriterFormat<'T> -> 'T Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn val up : _arg1:TreeZipper<'a> -> TreeZipper<'a> Full name: Tree-zipper-query.up val top : _arg1:TreeZipper<'a> -> TreeZipper<'a> Full name: Tree-zipper-query.top val t : TreeZipper<'a> val tz : TreeZipper<'a> Multiple items val unit : v:'a -> TreeZipper<'a> Full name: Tree-zipper-query.unit Build tree zipper with singleton tree -------------------- type unit = Unit Full name: Microsoft.FSharp.Core.unit val v : 'a val bindSub : f:('a -> TreeZipper<'a>) -> treeZip:TreeZipper<'a> -> TreeZipper<'a> Full name: Tree-zipper-query.bindSub Transform leaves in the current sub-tree of 'treeZip' into other trees using the provided function 'f' val f : ('a -> TreeZipper<'a>) val treeZip : TreeZipper<'a> val bindT : (Tree<'a> -> Tree<'a>) val t : Tree<'a> val current : Tree<'a> val path : Path<'a> Multiple items type TreeZipperBuilder = new : unit -> TreeZipperBuilder member Current : tz:TreeZipper<'a> -> 'a member For : tz:TreeZipper<'T> * f:('T -> TreeZipper<'T>) -> TreeZipper<'T> member Left : tz:TreeZipper<'a> -> TreeZipper<'a> member Right : tz:TreeZipper<'a> -> TreeZipper<'a> member Select : tz:TreeZipper<'a> * f:('a -> 'a) -> TreeZipper<'a> member Top : tz:TreeZipper<'a> -> TreeZipper<'a> member Up : tz:TreeZipper<'a> -> TreeZipper<'a> member Yield : v:'a -> TreeZipper<'a> Full name: Tree-zipper-query.TreeZipperBuilder -------------------- new : unit -> TreeZipperBuilder val x : TreeZipperBuilder member TreeZipperBuilder.For : tz:TreeZipper<'T> * f:('T -> TreeZipper<'T>) -> TreeZipper<'T> Full name: Tree-zipper-query.TreeZipperBuilder.For Enables the 'for x in xs do ..' syntax val tz : TreeZipper<'T> val f : ('T -> TreeZipper<'T>) member TreeZipperBuilder.Yield : v:'a -> TreeZipper<'a> Full name: Tree-zipper-query.TreeZipperBuilder.Yield Enables the 'yield x' syntax val tree : TreeZipperBuilder Full name: Tree-zipper-query.tree Global instance of the computation builder Multiple items type CustomOperationAttribute = inherit Attribute new : name:string -> CustomOperationAttribute member AllowIntoPattern : bool member IsLikeGroupJoin : bool member IsLikeJoin : bool member IsLikeZip : bool member JoinConditionWord : string member MaintainsVariableSpace : bool member MaintainsVariableSpaceUsingBind : bool member Name : string ... Full name: Microsoft.FSharp.Core.CustomOperationAttribute -------------------- new : name:string -> CustomOperationAttribute member TreeZipperBuilder.Left : tz:TreeZipper<'a> -> TreeZipper<'a> Full name: Tree-zipper-query.TreeZipperBuilder.Left member TreeZipperBuilder.Right : tz:TreeZipper<'a> -> TreeZipper<'a> Full name: Tree-zipper-query.TreeZipperBuilder.Right member TreeZipperBuilder.Up : tz:TreeZipper<'a> -> TreeZipper<'a> Full name: Tree-zipper-query.TreeZipperBuilder.Up member TreeZipperBuilder.Top : tz:TreeZipper<'a> -> TreeZipper<'a> Full name: Tree-zipper-query.TreeZipperBuilder.Top member TreeZipperBuilder.Current : tz:TreeZipper<'a> -> 'a Full name: Tree-zipper-query.TreeZipperBuilder.Current Extracts the current value and returns it member TreeZipperBuilder.Select : tz:TreeZipper<'a> * f:('a -> 'a) -> TreeZipper<'a> Full name: Tree-zipper-query.TreeZipperBuilder.Select Transform the current sub-tree using 'f' Multiple items type ProjectionParameterAttribute = inherit Attribute new : unit -> ProjectionParameterAttribute Full name: Microsoft.FSharp.Core.ProjectionParameterAttribute -------------------- new : unit -> ProjectionParameterAttribute val f : ('a -> 'a) custom operation: right Calls TreeZipperBuilder.Right custom operation: left Calls TreeZipperBuilder.Left custom operation: current Calls TreeZipperBuilder.Current Extracts the current value and returns it custom operation: map ('a) Calls TreeZipperBuilder.Select Transform the current sub-tree using 'f' custom operation: up Calls TreeZipperBuilder.Up custom operation: top Calls TreeZipperBuilder.Top val tree : TreeZipperBuilder Full name: Tree-zipper-query.tree Global instance of the computation builder val x : int val sample : TreeZipper<int> Full name: Tree-zipper-query.sample custom operation: left Calls TreeZipperBuilder.Left custom operation: map ('a) Calls TreeZipperBuilder.Select Transform the current sub-tree using 'f' custom operation: up Calls TreeZipperBuilder.Up custom operation: right Calls TreeZipperBuilder.Right custom operation: top Calls TreeZipperBuilder.Top Wed, 19 Dec 2024 14:22:47 +0100 05b1f46f-6491-4055-a232-d9277b84d952 http://tomasp.net/blog/manning-deep-dives.aspx Tomáš Petříček Manning: F# Deep Dives deal of the day The F# language has been around for longer than many people suspect. My first, completely outdated, blog post was from May 2006. The Microsoft Research releases, sometime around 2006 were the first stable versions that gained some interest and slowly attracted commercial users. A lot has changed since the early days. F# now includes powerful features like computation expressions and asynchronous workflows and F# 3.0 comes with unique type provider mechanism. There is an increasing number of users from diverse domains: F# is used to model complex domains in finance and science; asynchronous and concurrent features are used to write server-side components of social games and trading systems, but also in web programming; the expressivity of F# is used by machine learning experts to handle dirty data or classify XBox players. Moreover, the F# Software Foundation has been recently founded to support the collaboration between different commercial users, open-source community and academia. There is an increasing interest in F#, but many of those who approach it ask (excellent) questions such as: "In what problem domains can I benefit from F#?" or "How do I use F# in finance/science/gaming or web programming?" and most importantly "How do I approach different problems in F#?" Tue, 18 Dec 2024 17:19:57 +0100 48e5db33-5cf6-4a4b-a994-06758ee6813d http://tomasp.net/blog/more-events-autumn-2012.aspx Tomáš Petříček Learn F# at TechMesh and SkillsMetter Autumn is a busy period and I already invited you to a couple of interesting events, but there are two more events that you definitely should not miss. In only two weeks, you can come to two-day Progressive F# Tutorials packed with tutorials for both F# beginners and experts. At the beginning of December, the TechMesh Conference comes with three days of talks about alternative (and future) technologies. I'll be speaking at both Progressive F# Tutorials and TechMesh and I'm also doing a tutorial at TechMesh, so if you want to learn about F#, type providers in F# 3.0 and financial computing with F#, here are some talks that you should not miss... Sun, 21 Oct 2024 16:53:04 +0200 d676c6d3-58a6-4de5-9ce9-aa96d99db9a6 http://tomasp.net/blog/applicative-functors.aspx Tomáš Petříček Applicative functors: definition and syntax In a recent blog post, Edward Z. Yang talks about applicative functors. He mentions two equivalent definitions of applicative functors - the standard definition used in Haskell libraries (Applicative) and an alternative that has been also presented in the original paper, but is generally less familiar (Monoidal). The standard definition makes a perfect sense with the standard uses in Haskell, however I always preferred the alternative definition. Edward uses the alternative (Monoidal) definition to explain the laws that should hold about applicative functors and to explain commutative applicative functors, but I think it is even more useful. The Monoidal definition fits nicely with a trick that you can use to encode applicative functors in C# using LINQ and I also used it as a basis for an F# syntax extension that allows writing code using applicative functors in a similar style as using monads (which is discussed in my draft paper about writing abstract computations in F#). And I also think that commutative applicative functors deserve more attention. Tue, 21 Aug 2024 14:23:19 +0200 4863a4f4-1f9e-4e67-a5f1-34175e6ef6a8 http://tomasp.net/blog/type-first-development.aspx Tomáš Petříček Why type-first development matters Using functional programming language changes the way you write code in a number of ways. Many of the changes are at a small-scale. For example, you learn how to express computations in a shorter, more declarative way using higher-order functions. However, there are also many changes at a large-scale. The most notable one is that, when designing a program, you start thinking about the (data) types that represent the data your code works with. In this article, I describe this approach. Since the acronym TDD is already taken, I call the approach Type-First Development (TFD), which is probably a better name anyway. The development is not driven by types. It starts with types, but the rest of the implementation can still use test-driven development for the implementation. This article demonstrates the approach using a case study from a real life: My example is a project that I started working on with a friend who needed a system to log journeys with a company car (for expense reports). Using the type-first approach made it easier to understand and discuss the problem. In many ways, TFD is a very simple approach, so this article just gives a name to a practice that is quite common among functional and F# programmers (and we have been teaching it at our F# trainings for the last year)... Thu, 16 Aug 2024 00:21:21 +0200 73b766d6-5030-4d12-a04d-72bb80f6fd4a http://tomasp.net/blog/events-autumn-2012.aspx Tomáš Petříček F# Courses and Talks for Autumn 2012 Similarly to the last year, I already have a number of F# events planned for the end of the summer and autumn that I'd like to invite you to! The Visual Studio 2012 has been completed recently and it comes with F# 3.0. For me, this means two things. Firstly, it is the second Visual Studio version of F#, which means that functional programming is worth taking seriously. Secondly, F# 3.0 comes with type providers, which is a killer feature for working with data. No matter if you're a C# programmer now to functional programming or if you're an F# user in the real-world, I hope you can find some interesting and useful event below! The two main things that I'm going to be involved in are SkilsMatter trainings in London and New York and a few events at the biggest functional conference (ICFP) in Copenhagen... Wed, 08 Aug 2024 03:47:08 +0200 de1648f3-512a-4992-93cf-f67448948814 http://dajbych.net/portable-libraries-jedna-knihovna-pro-vsechny-platformy Václav Dajbych Portable Libraries – jedna knihovna pro všechny platformy Portable Class Library je univerzální .NET knihovna. Je užitečná pro sdílení kódu například mezi WPF, Windows Phone a Metro style aplikacemi. Může obsahovat vše, co je pro platformy, pro které je určená, společné. Díky doplňku pro Visual Studio 2010 je možné ji začít používat ihned. Jelikož se platforma .NET poslední roky poněkud tříští, je Portable Library velmi vítaný tmelící prvek. Už není nutné kompilovat knihovny pro různé .NET platformy. Thu, 19 Jul 2024 00:00:00 +0200 8b8f6824-cf71-4a40-b9fc-cd2f99820873 http://tomasp.net/blog/variance-explained.aspx Tomáš Petříček The theory behind covariance and contravariance in C# 4 In C# 4.0, we can annotate generic type parameters with out and in annotations to specify whether they should behave covariantly or contravariantly. This is mainly useful when using already defined standard interfaces. Covariance means that you can use IEnumerable<string> in place where IEnumerable<object> is expected. Contravariance allows you to pass IComparable<object> as an argument of a method taking IComparable<string>. So far, so good. If you already learned about covariance and contravariance in C# 4, then the above two examples are probably familiar. If you're new to the concepts, then the examples should make sense (after a bit of thinking, but I'll say more about them). However, there is still a number of questions. Is there some easy way to explain the two concepts? Why one option makes sense for some types and the other for different types? And why the hell is it called covariance and contravariance anyway? In this blog post, I'll explain some of the mathematics that you can use to think about covariance and contravariance. Tue, 19 Jun 2024 14:24:52 +0200 aafb8364-3949-4b96-bef5-7cdf6677b5e1 http://tomasp.net/blog/agent-event-reporting.aspx Tomáš Petříček Reporting events from F# Agents Over the last year, I wrote quite a lot of articles about agent-based programming in F#. Agents (inspired by Erlang) provide a great abstraction for writing concurrent and scalable systems. They are a great fit for both server-side development (for example, handling a large number of concurrent requests), but also for user interface (for example, keeping state in an application with background tasks and interactive interface). When writing reusable agents, we usually encapsulate agent in an F# object type. The type provides methods for sending messages to the agent. However, sometimes the agent also needs to report some state change that can be handled by another interested agent. This is done using F# events. However, F# events do not specify threading behaviour, so there is a number of options. In this article (inspired by a recent email discussion), I describe three ways of reporting events from an agent. The options differ in what thread is used to report the event. Choosing the right option is important as it affects scalability and simplicity of your agent-based code. Sat, 16 Jun 2024 00:23:35 +0200 04f22e25-03bc-40cd-a4c8-1f32a017397f http://dajbych.net/building-view-model-over-application-data-storage Václav Dajbych Building view model over application data storage Metro style application must contain a massive local cache in order to achieve fast and fluid user experience. Since data could be refreshed only by background task, every data model must be stored in the local application data storage. While I have been writing a code to transfer application data between model classes and local storage I realized I can write a tiny layer doing this job for me automatically. This article describes how to use it. Fri, 18 May 2024 00:00:00 +0200 62cb4105-1bbc-4877-97ef-93d4cfd3cb1b http://dajbych.net/double-layered-application-with-powershell-in-the-middle Václav Dajbych Double layered application with PowerShell in the middle There are several reasons why use PowerShell. The most significant advantage is ability to use script instead of user interface. PowerShell is for administrator almost the same environment as a console application for developer. When the core of your application is highly independent so it is extreme easy build a console application based on it consider using PowerShell layer. Sat, 21 Apr 2024 00:00:00 +0200 853ddf4d-0e19-41ae-926f-684c3d5d3ec8 http://tomasp.net/blog/fsharp-academia.aspx Tomáš Petříček F# in Academia: Present at upcoming events! The F# language was born as a combination of the pragmatic and real-world .NET platform and functional programming, which had a long tradition in academia. Many useful ideas or libraries in F# (like asynchronous workflows and first-class events) are inspored by research in functional programming (namely, the work on monads, continuations and functional reactive programming). Exchanging the ideas between the research community and the real-world is one of the areas where F# excels. Indeed, the first applicatiosn of F# inside Microsoft (in the Machine Learning group at Cambridge) were all about this - combining research in machine learning with a language that can be easily used in practice. However, F# and the F# users also made numerous contributions to the programming langauge research community. Influential ideas that come from F# include active patterns and the F# style of meta-programming for translating F# to JavaScript). I think there is a lot more that the academic community can learn from the F# community, so I'd like to invite you to talk about your ideas at two upcoming academic events! What, why, when, where and how? Continue reading! Mon, 16 Apr 2024 00:19:04 +0200 5d10db5c-fc5c-409b-83c6-66d7c8526c4d http://tomasp.net/blog/joinads-async-implement.aspx Tomáš Petříček TryJoinads (VII.) - Implementing joinads for async workflows The article Asynchronous workflows and joinads gives numerous examples of programming with asynchronous workflows using the match! construct. Briefly, when matching on multiple asynchronous workflows, they are executed in parallel. When pattern matching consists of multiple clauses, the clause that matches on computations that complete first gets executed. These two behaviours are implemented by the Merge and the Choose operation of joinads. Additionally, asynchronous workflows require the Alias operation, which makes it possible to share the result of a started asynchronous workflow in multiple clauses. In this article, we look at the definition of the additional AsyncBuilder operations that enable the match! syntax. We do not look at additional examples of using the syntax, because these can be found in a previous article. Note: This blog post is a re-publication of a tutorial from the TryJoinads.org web page. If you read the article there, you can run the examples interactively and experiment with them: view the article on TryJoinads. Fri, 23 Mar 2025 17:21:51 +0100 70941c48-7af9-447c-864b-3e2f65af7bb3 http://tomasp.net/blog/joinads-parsing.aspx Tomáš Petříček TryJoinads (VI.) - Parsing with joinads In functional programming, parser combinators are a powerful way of writing parsers. A parser is a function that, given some input, returns possible parsed values and the rest of the input. Parsers can be written using combinators for composition, for example run two parsers in sequence or perform one parser any number of times. Parsers can also implement the monad structure. In some cases, this makes the parser less efficient, but it is an elegant way of composing parsers and we can also benefit from the syntactic support for monads. In this article, we implement a simple parser combinators for F# and we look what additional expressive power we can get from the joinad structure and match! construct. This article is largely based on a previous article "Fun with Parallel Monad Comprehensions", which can be found on the publications page. Note: This blog post is a re-publication of a tutorial from the TryJoinads.org web page. If you read the article there, you can run the examples interactively and experiment with them: view the article on TryJoinads. Wed, 21 Mar 2025 16:27:06 +0100 5da19707-8ee8-4060-8ee1-756b4698f847 http://tomasp.net/blog/qcon-async-fsharp.aspx Tomáš Petříček Asynchronous client/server in F# (QCon 2012) Last week, I gave a talk on asynchronous programming in F# at London QCon 2012. The talk was a part of The Rise of Scala & Functional Programming track organized by Charles Humble. Reactive and asynchronous programming was a topic that was repeated a couple of times during the whole session - Sadek Drobi talked about non-blocking reactive web framework Play2 and Damien Katz talked about Erlang and CouchDB. I used the one hour slot to implement "Rectangle Drawing App" - a simple application that shows how to write complete client-server application just using F#. On the server-side, I used asynchronous workflows to write HTTP server with an F# agent. On the client-side, I used asynchronous workflows to express user interface logic and the Pit project to run F# code as JavaScript that works everywhere. The app definitely had a huge commercial potential: Mon, 12 Mar 2025 01:09:02 +0100 bc0b730c-deb8-40c7-b3c0-00410f84e399 http://tomasp.net/blog/joinads-options.aspx Tomáš Petříček TryJoinads (V.) - Implementing the option joinad This article shows how to implement the joinad structure for one of the simplest monads - the option<'T> type. This is a slightly oversimplified example. The match! construct can be used to write patterns that specify that a monadic value (in this case option<'T>) should contain a certain value, or we can specify that we do not require a value. When working with options, this means the same thing as matching the value against Some and against _, respectively. However, the example demonstrates the operations that need to be implemented and their type signatures. Later articles give more interesting examples including parsers and asynchronous workflows (and you can explore other examples if you look at the FSharp.Joiands source code at GitHub). Note: This blog post is a re-publication of a tutorial from the TryJoinads.org web page. If you read the article there, you can run the examples interactively and experiment with them: view the article on TryJoinads. Fri, 02 Mar 2025 13:24:21 +0100 960e4d03-b9da-49b7-816a-f9293294ece4 http://tomasp.net/blog/joinads-join-calculus.aspx Tomáš Petříček TryJoinads (IV.) - Concurrency using join calculus Join calculus provides a declarative way of expressing asynchronous synchronization patterns. It has been use as a basis for programming languages (JoCaml and COmega), but also as a basis for libraries (embedded in C# and Scala). Using joinads, it is possible to embed join calculus in F# with a nice syntax using the match! construct. Formally, join calculus does not form a monad, but it can be viewed as a version of joinad as described in the first paper on joinads. The programming model is based on channels and join patterns. A channel can be viewed as a thread-safe mailbox into which we can put values without blocking the caller. In some sense, this is quite similar to F# agents. A join pattern is then a rule saying that a certain combination of values in channels should trigger a specific reaction (and remove values from the channels). The ability to match on multiple channels distinguishes join calculus from F# agents. Note: This blog post is a re-publication of a tutorial from the TryJoinads.org web page. If you read the article there, you can run the examples interactively and experiment with them: view the article on TryJoinads. Wed, 22 Feb 2025 17:38:40 +0100 6c4d05dd-89e8-4469-ab31-674a09607fa9 http://tomasp.net/blog/joinads-agents.aspx Tomáš Petříček TryJoinads (III.): Agent-based programming Another area where the match! syntax can be used is when programming with F# agents, implemented by the MailboxProcessor type. Formally, agents do not form the monad structure in a useful way - when programming with agents, we do not compose a new agents, but instead we write code that (imperatively) receives messages from the agent's mailbox and handles them. This article demonstrates an agent { ... } computation builder that can be used for implementing the body of an agent. Normally, the body of an agent is an asynchronous workflow. The code in the body uses let! to perform asynchronous operations, most importantly to call inbox.Receive to get the next message from the inbox. When the agent intends to handle only certain kinds of messages, it can use inbox.Scan. When using the agent builder, pattern matching on messages can be written using match! and it is possible to write code that ignores certain types of messages simply by writing an incomplete pattern matching. Note: This blog post is a re-publication of a tutorial from the TryJoinads.org web page. If you read the article there, you can run the examples interactively and experiment with them: view the article on TryJoinads. Mon, 20 Feb 2025 12:36:10 +0100 3c8c2af7-b1e2-41b9-b42d-6fae8cc8b2b1 http://tomasp.net/blog/joinad-tasks.aspx Tomáš Petříček TryJoinads (II.): Task-based parallelism The implementation of joinad operations for the Task<'T> type is quite similar to the implementation of Async<'T>, because the two types have similar properties. They both produce at most one value (or an exception) and they both take some time to complete. Just like for asynchronous workflows, pattern matching on multiple computations using match! gives us a parallel composition (with the two tasks running in parallel) and choice between clauses is non-deterministic, depending on which clause completes first. Unlike asynchronous workflows, the Task<'T> type does not require any support for aliasing. A value of type Task<'T> represents a running computation that can be accessed from multiple parts of program. In this sense, the type Async<'T> is more similar to a function unit -> Task<'T> than to the type Task<'T> itself. The key difference between tasks and asynchronous workflows is that the latter provides better support for writing non-blocking computations that involve asynchronous long-running operations such as I/O or waiting for a certain event. Tasks are more suitable for high-performance CPU-intensive computations. Note: This blog post is a re-publication of a tutorial from the TryJoinads.org web page. If you read the article there, you can run the examples interactively and experiment with them: view the article on TryJoinads. Fri, 17 Feb 2025 13:10:29 +0100 ac8b0229-7289-49ff-99d0-a7c9b774cd0a http://tomasp.net/blog/joinads-async-prog.aspx Tomáš Petříček TryJoinads (I.) - Asynchronous programming Asynchronous workflows provide a way of writing code that does not block a thread when waiting for a completion of long-running operation such as web service call, another I/O operation or waiting for the completion of some background operation. In this article, we look at the new expressive power that joinads add to asynchronous workflows written using the async { ... } block in F#. Note: This blog post is a re-publication of a tutorial from the TryJoinads.org web page. If you read the article there, you can run the examples interactively and experiment with them: view the article on TryJoinads. Mon, 13 Feb 2025 17:35:44 +0100 d40eba63-f872-4ab7-8564-65f904cd6f39 http://tomasp.net/blog/introducing-tryjoinads.aspx Tomáš Petříček Introducing TryJoinads.org (Click for a larger version) If you have been following my blog, you've probably already heard of joinads. It is a research extension of F# computation expressions (or monads in Haskell). The extension makes computation expressions more useful in domains like parallel, concurrent and reactive programming. However, it can be used for any type of computation including, for example, parsers. If you're interested in detailed description, you can find it in two academic papers that I blogged about previously: PADL 2011 and Haskell 2011. The extension adds a keyword match! - as the syntax suggests, it is akin to pattern matching using match, but instead of pattern matching on values, you can pattern match on computations like Async<'T> (or on other monadic values). Just like other features of computation expressions, the match! syntax is translated to applications of several methods defined by the computation builder. I won't say more about joinads in this post, because you can now easily try joinads yourself... Mon, 13 Feb 2025 16:21:03 +0100 8a06e572-883c-4b6e-af07-707979e19a4c http://dajbych.net/pripojeni-k-telefonnim-sitim-z-windows-8 Václav Dajbych Připojení k telefonním sítím z Windows 8 Windows 8 umožňuje připojení k 3G a 4G sítím bez instalace hardwaru či softwaru třetích stran. Je schopný po probuzení z režimu spánku obnovit připojení do jedné sekundy. Windows Update nebude stahovat aktualizace, pokud je k dispozici jen připojení, které je placené podle objemu přenesených dat. Všechny aplikace na Windows Store musí dbát na objem přenášených dat, pokud se do sítě připojují. Sun, 22 Jan 2025 00:00:00 +0100