Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
wraikny committed Oct 11, 2024
1 parent e65ac94 commit 4eb993a
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 29 deletions.
3 changes: 1 addition & 2 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ let dotnet cmd arg =
res.Messages |> String.concat "\n" |> Trace.trace
failwithf "failed 'dotnet %s %s'" cmd arg

let fsiExec path =
dotnet "fsi" path
let fsiExec path = dotnet "fsi" path

let release = ReleaseNotes.load "RELEASE_NOTES.md"

Expand Down
10 changes: 5 additions & 5 deletions example/example.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ type Handler2 =
// capture the handler
Eff.capture
<| fun h ->
printfn "[%s]: RandomInt(%d)" h.name a
rand.Next(a) |> k
printfn "[%s]: RandomInt(%d)" h.name a
rand.Next(a) |> k

static member inline Handle(Logging a, k) =
// capture the handler
Eff.capture
<| fun h ->
printfn "[%s]: Logging(%A)" h.name a
printfn "%A" a
k ()
printfn "[%s]: Logging(%A)" h.name a
printfn "%A" a
k ()


let main () =
Expand Down
12 changes: 6 additions & 6 deletions example/example.statemachine.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module C =
x
|> function
| Base i -> sprintf "Base (%d)" i
| StateOfB (s, _) -> sprintf "StateOfB (%O)" s
| StateOfB(s, _) -> sprintf "StateOfB (%O)" s

type Msg =
| Apply
Expand All @@ -71,7 +71,7 @@ module C =
let! i = ESM.stateEnter { B.State.b = i }
return Base i |> ESM.Pending

| StateOfB (s, k), MsgOfB m -> return ESM.stateMap (B.update m) (s, k)
| StateOfB(s, k), MsgOfB m -> return ESM.stateMap (B.update m) (s, k)

| _ -> return ESM.Pending state
}
Expand All @@ -88,8 +88,8 @@ module Program =
x
|> function
| StateOfA s -> sprintf "StateOfA (%O)" s
| StateOfB (s, _) -> sprintf "StateOfB (%O)" s
| StateOfC (s, _) -> sprintf "StateOfC (%O)" s
| StateOfB(s, _) -> sprintf "StateOfB (%O)" s
| StateOfC(s, _) -> sprintf "StateOfC (%O)" s

// EffFs.StateMachine
type StateMachine with
Expand Down Expand Up @@ -128,9 +128,9 @@ module Program =
let s = A.update m s
return StateOfA s

| StateOfB (s, k), Msg.MsgOfB m -> return ESM.stateMap (B.update m) (s, k)
| StateOfB(s, k), Msg.MsgOfB m -> return ESM.stateMap (B.update m) (s, k)

| StateOfC (s, k), Msg.MsgOfC m -> return! ESM.stateMapEff (C.update m) (s, k)
| StateOfC(s, k), Msg.MsgOfC m -> return! ESM.stateMapEff (C.update m) (s, k)

| _ -> return state
}
Expand Down
6 changes: 2 additions & 4 deletions src/EffFs/DynamicHandler.fs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ type DynamicHandlerBuilder =

[<CustomOperationAttribute("handle")>]
member inline __.AddHandle
(
(vh, d: (Type * obj) list),
f: ^e -> 'a
) : _ when 'e: (static member Effect: 'e -> EffectTypeMarker<'a>) =
((vh, d: (Type * obj) list), f: ^e -> 'a)
: _ when 'e: (static member Effect: 'e -> EffectTypeMarker<'a>) =
let h: obj -> 'a = unbox< ^e> >> f
(vh, (typeof<'e>, box h) :: d)

Expand Down
4 changes: 1 addition & 3 deletions src/EffFs/EffFs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
open System.ComponentModel

[<AbstractClass; Sealed>]
type EffectTypeMarker<'a> =
class
end
type EffectTypeMarker<'a> = class end

[<Struct>]
type Eff<'a, 'h> = Eff of ('h -> 'a)
Expand Down
16 changes: 7 additions & 9 deletions src/EffFs/Library/StateMachine.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ type StateEnterEffect< ^s, 'o when ^s: (static member StateOut: ^s -> EffectType


let inline handle
(
StateEnterEffect.StateEnterEffect (s: ^s),
k: 'o -> Eff<'os, ^h>
) : Eff< ^state, ^h > when ^state: (static member StateEnter: ^s * ('o -> 'os) -> ^state) =
(StateEnterEffect.StateEnterEffect(s: ^s), k: 'o -> Eff<'os, ^h>)
: Eff< ^state, ^h > when ^state: (static member StateEnter: ^s * ('o -> 'os) -> ^state) =
Eff.capture (fun h -> s |> callStateEnter (k >> Eff.handle h) |> Eff.pure')


Expand All @@ -31,11 +29,11 @@ type StateStatus<'s, 'o> =
| Completed of output: 'o

static member inline StateEnter
(
s: ^a,
k: 'b -> 'c
) : StateStatus< ^state, _ > when ^a: (static member StateOut: ^a -> EffectTypeMarker<'b>) and ^state: (static member StateEnter:
^a * ('b -> 'c) -> ^state) =
(s: ^a, k: 'b -> 'c)
: StateStatus< ^state, _ >
when ^a: (static member StateOut: ^a -> EffectTypeMarker<'b>)
and ^state: (static member StateEnter: ^a * ('b -> 'c) -> ^state)
=
Pending(callStateEnter k s)


Expand Down

0 comments on commit 4eb993a

Please sign in to comment.