Skip to content
This repository was archived by the owner on Feb 22, 2022. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions src/Freya.Core/Core.fs
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ module Freya =
let apply (m: Freya<'a>, f: Freya<'a -> 'b>) : Freya<'b> =
fun s ->
Job.bind (fun (f, s) ->
Job.bind (fun (a, s) ->
Job.result (f a, s)) (m s)) (f s)
Job.map (fun (a, s) ->
(f a, s)) (m s)) (f s)

let bind (m: Freya<'a>, f: 'a -> Freya<'b>) : Freya<'b> =
fun s ->
Expand All @@ -173,8 +173,7 @@ module Freya =

let delay (f: unit -> Freya<'a>) : Freya<'a> =
fun s ->
Job.bind (fun (a, s) ->
Job.result (a, s)) (f () s)
f () s

let init (a: 'a) : Freya<'a> =
fun s ->
Expand All @@ -185,8 +184,8 @@ module Freya =

let map (m: Freya<'a>, f: 'a -> 'b) : Freya<'b> =
fun s ->
Job.bind (fun (a, s) ->
Job.result (f a, s)) (m s)
Job.map (fun (a, s) ->
(f a, s)) (m s)

let zero () : Freya<unit> =
fun s ->
Expand All @@ -212,8 +211,7 @@ module Freya =

let delay (f: unit -> Freya<'a>) : Freya<'a> =
fun s ->
async.Bind (f () s, fun (a, s) ->
async.Return (a, s))
f () s

let init (a: 'a) : Freya<'a> =
fun s ->
Expand Down Expand Up @@ -252,14 +250,14 @@ module Freya =

let fromAsync (a: 'a, f: 'a -> Async<'b>) : Freya<'b> =
fun s ->
Job.bind (fun (b) ->
Job.result (b, s)) (Job.fromAsync (f a))
Job.map (fun b ->
(b, s)) (Job.fromAsync (f a))

let map2 (f: 'a -> 'b -> 'c, m1: Freya<'a>, m2: Freya<'b>) : Freya<'c> =
fun s ->
Job.bind (fun (a, s) ->
Job.bind (fun (b, s)->
Job.result (f a b, s)) (m2 s)) (m1 s)
Job.map (fun (b, s)->
(f a b, s)) (m2 s)) (m1 s)

#else

Expand Down Expand Up @@ -294,8 +292,8 @@ module Freya =
| Some memo ->
Job.result (memo, s)
| _ ->
Job.bind (fun (memo, s) ->
Job.result (memo, Aether.Optic.set memo_ (Some memo) s)) (m s)
Job.map (fun (memo, s) ->
(memo, Aether.Optic.set memo_ (Some memo) s)) (m s)

#else

Expand Down