Skip to content

Commit

Permalink
send should return unit. fez_unit -> unit
Browse files Browse the repository at this point in the history
  • Loading branch information
kjnilsson committed Dec 8, 2017
1 parent 2b8066a commit 360ef6e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/Fez.Core.erl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ spawn(F) -> erlang:spawn(F).
'op_LessBang'() ->
fun (Dst) ->
fun (Msg) ->
Dst ! Msg
Dst ! Msg,
unit
end
end.

Expand Down
3 changes: 3 additions & 0 deletions src/fez.core/core.fs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ let spawn (f : unit -> unit) : Pid =
let self () = P

let send<'T> (dst: Pid) (msg: 'T) : unit =
// in erlang `send` returns the msg
// in fsharp this would just cause a warning so we
// just return unit instead
()

let (<!) = send
Expand Down
17 changes: 6 additions & 11 deletions src/fez/Compiler.fs
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ module Compiler =
else s

let fezUnit =
cerl.Exp (cerl.Constr (cerl.Lit (cerl.LAtom (cerl.Atom "fez_unit"))))
cerl.Exp (cerl.Constr (cerl.Lit (cerl.LAtom (cerl.Atom "unit"))))

let (|IsFezUnit|_|) e =
match e with
| cerl.Exp (cerl.Constr (cerl.Lit (cerl.LAtom (cerl.Atom "fez_unit")))) ->
| cerl.Exp (cerl.Constr (cerl.Lit (cerl.LAtom (cerl.Atom "unit")))) ->
Some e
| _ -> None

Expand Down Expand Up @@ -450,7 +450,7 @@ module Compiler =
| :? string as s -> litString s
| :? bool as b -> litAtom (toLowerString b)
| null -> //unit
litAtom "fez_unit" //Special casing a value here for unit for now
litAtom "unit" //Special casing a value here for unit for now
| x -> failwithf "mapConst: not impl %A" x

let ioLibFormat nm str t args =
Expand Down Expand Up @@ -608,17 +608,12 @@ module Compiler =
//method on type rather than nested module
fe.LogicalName + "." + f.LogicalName
//add callee as first arg if method dispatch
//TODO: refactor - stale
let args, nm =
let args, nm =
eraseUnit exprs
|> foldNames nm processExpr
let args = args |> stripFezUnit |> List.map (flattenLambda [])
match callee with
| Some o ->
let o, nm = processExpr nm o
o :: args, nm
| None -> args, nm
args, nm
let numArgs = List.length args
let func, nm = mkFunction nm name numArgs
let func = func |> cerl.Fun |> constr
Expand All @@ -629,7 +624,7 @@ module Compiler =
let args, nm =
eraseUnit exprs
|> foldNames nm processExpr
// remove fez_unit
// remove unit
// flatten any lambda args
let args = args |> stripFezUnit |> List.map (flattenLambda [])
let m = fe.FullName |> safeAtom
Expand Down Expand Up @@ -1057,7 +1052,7 @@ process dictionary call the Ref.release() method.
| B.Lambda (IsUnitArg p, expr) ->
let unitName, nm = safeVar true nm p.LogicalName
let body, nm = processExpr nm expr
// wrap body in let so that unit arg is mapped to fez_unit
// wrap body in let so that unit arg is mapped to unit
let body = mkLet unitName fezUnit body |> constr
cerl.Lambda ([], body) |> constr, nm
| B.Lambda (p, expr) ->
Expand Down

0 comments on commit 360ef6e

Please sign in to comment.