Look up words in the dictionary.
If they are not built-in, which means you can't "shadow" built-ins with "inscribe", which may or may not turn out to be what we want?
This commit is contained in:
parent
4acdec71ed
commit
edfd7c526f
|
|
@ -1,7 +1,7 @@
|
|||
module Joy exposing (doit, JoyDict)
|
||||
|
||||
import Bitwise
|
||||
import Dict exposing (Dict)
|
||||
import Dict exposing (Dict, get)
|
||||
import Result exposing (andThen)
|
||||
import String exposing (replace, words)
|
||||
|
||||
|
|
@ -42,6 +42,10 @@ joy_eval symbol stack expression dict =
|
|||
Err msg ->
|
||||
if "Unknown word." == msg then
|
||||
-- Look up word in dictionary.
|
||||
case get symbol dict of
|
||||
Just definition ->
|
||||
Ok (stack, definition ++ expression, dict)
|
||||
Nothing ->
|
||||
Err ("Unknown word: " ++ symbol)
|
||||
else
|
||||
Err msg
|
||||
|
|
|
|||
Loading…
Reference in New Issue