Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
HigherKindedTypes.Specs
HigherKindedTypes
.gitignore
README.md
global.json

README.md

higher-kinded-types

Allows for higher-kinded generic types in F# (a.k.a. 'M<'T>) through the use of some compiler tricks.

Inspired by https://github.com/palladin/Higher/. This library attempts to be more accessible to those less familiar with the subject, but is far less mature in it's capabilities

usage

open HigherKindedTypes
...
let avg x y = (x + y) / 2.
let pairwiseAverage xs ys = 
  Collection.zip xs ys
  |> Functor.map avg

let lstXs = [1. .. 3.]
let lstYs = [3. .. 5.]

let ans = //ans is List<double> at compile-time
  pairwiseAverage (lstXs |> List.toHigherKindedType) (lstYs |> List.toHigherKindedType)
  |> List.fromHigherKindedType

let arXs = [|1. .. 3.|]
let arYs = [|3. .. 5.|]

let ans = //ans is Array<double> at compile-time
  pairwiseAverage (lstXs |> Array.toHigherKindedType) (lstYs |> Array.toHigherKindedType)
  |> Array.fromHigherKindedType

methodology

You can’t perform that action at this time.