Skip to content

Commit

Permalink
Allow non F# union-types to be used as messages
Browse files Browse the repository at this point in the history
fixes #20

Actually, I think this should have created problems for anyone not using F#-unions.
  • Loading branch information
matthid authored and et1975 committed Feb 22, 2019
1 parent 7791b6d commit 71dd03e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/debugger.fs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,12 @@ module Program =
open FSharp.Reflection

let inline private duName (x:'a) =
match FSharpValue.GetUnionFields(x, typeof<'a>) with
| case, _ -> case.Name
let t = typeof<'a>
if (isNull t?cases)
then "not-a-f#-union"
else
match FSharpValue.GetUnionFields(x, t) with
| case, _ -> case.Name

let inline private getCase<'msg> (cmd: 'msg) : obj =
createObj ["type" ==> duName cmd
Expand Down

0 comments on commit 71dd03e

Please sign in to comment.