You’re better off using Exceptions

Worth reading, for sure.

Eirik Tsarpalis' blog

Exception handling is an error management paradigm that has often been met with criticism. Such criticisms typically revolve around scoping considerations, exceptions-as-control-flow abuse or even the assertion that exceptions are really just a type safe version of goto. To an extent, these seem like valid concerns but it is not within the scope of this article to address those per se.

Such concerns resonate particularly well within FP communities, often taken to the extreme: we should reject exceptions altogether, since code that throws is necessarily impure. In the F# community, this opinion is in part realized by advocating alternatives like result types and railway-oriented programming. In essence, these approaches follow the Either monad found in Haskell, but often intentionally avoiding the use of do notation/computation expressions (since that’s just interpreted exception semantics).

The TL;DR version of the approach is that we define a union type for results that looks…

View original post 920 more words

F# Weekly #8, 2017

Welcome to F# Weekly,

A roundup of F# content from this past week:

News

Videos

Blogs

F# vNext

Open source projects

New Releases

That’s all for now. Have a great week.

Previous F# Weekly edition – #7Subscribe

F# Weekly #7, 2017

Welcome to F# Weekly,

A roundup of F# content from this past week:

News

Videos

Blogs

F# vNext

Open source projects

  • smvp – Simple F# API over the Microsoft MVP API
  • AspNetCore.Lambda – An attempt to make ASP.NET Core more functional.
  • fsharp-gcloud-functions – Getting some F# into Google Cloud functions
  • MBrace.Sql – WIP – SQL Layer for running queries against MBrace data stores

New Releases

That’s all for now. Have a great week.

Previous F# Weekly edition – #6Subscribe

F# Weekly #6, 2017

Welcome to F# Weekly,

A roundup of F# content from this past week:

News

Videos

Blogs

F# vNext

Open source projects

New Releases

That’s all for now. Have a great week.

Previous F# Weekly edition – #5Subscribe

F# Weekly #5, 2017

Welcome to F# Weekly,

A roundup of F# content from this past week:

News

Videos

Blogs

F# vNext

Open source projects

  • IoTHubFsharp – Get started with Azure IoT Hub in F#
  • neovimfs – Neovimfs is that Fsi works on Suave server

New Releases

That’s all for now. Have a great week.

Previous F# Weekly edition – #4Subscribe

ASP.NET MVC with Simple Windows Authorization

A lot of enterprises use Active Directory (AD) to manage user accounts and Security Groups to manage access to resources.

So (I think) that there is a common task when you want to create some internal resource that will provide certain functionality for your team, but you do not want to expose your data outside. We can easily enable Windows authentication, however usually we also need to add an authorization(limit access to certain groups)

The task is simple, but I do not know why it is so hard to find manual for this. Steps are as follows:

  • Enable Windows authentication in web.config
  • Add WindowsTokenRoleProvider that transforms all Security Groups to ASP.NET Roles
  • Configure Authorization rules based on roles
  • Disable anonymous authentication for IIS Express.

Changes in Web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  ...
  <system.web>
    ...
    <authentication mode="Windows" />
    <authorization>
      <allow roles="DOMAIN\MyTeam" />
      <deny users="*"/>
    </authorization>
    <roleManager cacheRolesInCookie="false" defaultProvider="WindowsProvider" enabled="true">
      <providers>
        <clear />
        <add name="WindowsProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
      </providers>
    </roleManager>
  </system.web>
  ...
</configuration>

Changes in project file:

<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    ...
    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
    <UseIISExpress>true</UseIISExpress>
    <IISExpressSSLPort />
    <IISExpressAnonymousAuthentication>disabled</IISExpressAnonymousAuthentication>
    <IISExpressWindowsAuthentication>enabled</IISExpressWindowsAuthentication>
    <IISExpressUseClassicPipelineMode />
    <UseGlobalApplicationHostFile />
    ...
  </PropertyGroup>
  ...

P.S. You can use security groups to restrict access to Controllers/Views based on the roles (AuthorizeAttribute)

F# Weekly #4, 2017

Welcome to F# Weekly,

A roundup of F# content from this past week:

News

Videos

Blogs

F# vNext

Open source projects

New Releases

That’s all for now. Have a great week.

Previous F# Weekly edition – #3Subscribe

F# Weekly #3, 2017

Welcome to F# Weekly,

A roundup of F# content from this past week:

News

Videos

Blogs

F# vNext

Open source projects

  • Microsoft/fsharplu – This library provides a set of F# helpers for string manipulations, logging, collection data structures, file operations, text processing, security, async, parsing, diagnostics, configuration files and Json serialization.
  • expecto-adapter – Visual Studio test adapter for Expecto
  • fue – F# templating library with simple syntax designed for smooth work with F# types.
  • pipes-and-filters – Sources for the pipes and filters presentation

New Releases

That’s all for now. Have a great week.

Previous F# Weekly edition – #2Subscribe

F# Weekly #2, 2017

Welcome to F# Weekly,

A roundup of F# content from this past week:

News

Videos

Blogs

F# vNext

Open source projects

New Releases

That’s all for now. Have a great week.

Previous F# Weekly edition – #1Subscribe