LoginSignup
1

More than 5 years have passed since last update.

ついでにF#でparamorphism/apomorphism

Last updated at Posted at 2014-03-03

前回の投稿に続いて。相変わらず応用先は不明。

// 前回の定義を前提としています。

let rec ana phi x = 
    let z : F<'c> = (x |> phi)
    Wrap(z.fmap(ana phi) z)

let fork f g x = (f x, g x)

let rec para phi x =
    let y = (x |> unIn)
    y.fmap (fork (para phi) id) y |> phi

type Sum<'a,'b> =
    | InL of 'a
    | InR of 'b

let join f g x =
    match x with
    | InL(a) -> f a
    | InR(b) -> g b

let rec apo phi x =
    let (y : F<Sum<'c, Nu<'a>>>) = x |> phi
    Wrap(y.fmap(join (apo phi) id) y)

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1