diff options
| author | LLLL Colonq <llll@colonq> | 2025-06-16 05:42:58 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2025-06-16 05:42:58 -0400 |
| commit | a421eb9bdddfa7e2765456f756833d8941ac7a08 (patch) | |
| tree | fb07429aff4bf970435c6465ffa56eb8eb54d28c /fig-utils | |
| parent | 7c3e41979478d6826f73a956a26c967aae1687a2 (diff) | |
fig-web: Initial puzzle site
Diffstat (limited to 'fig-utils')
| -rw-r--r-- | fig-utils/csrc/fig.c | 4 | ||||
| -rw-r--r-- | fig-utils/src/Fig/Utils/FFI.hs | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/fig-utils/csrc/fig.c b/fig-utils/csrc/fig.c index e828e71..2ad1005 100644 --- a/fig-utils/csrc/fig.c +++ b/fig-utils/csrc/fig.c @@ -33,9 +33,9 @@ int check_answer(char **failure, char *code, char *data) { check_answer_catch_body, &args, check_answer_catch_handler, NULL, check_answer_catch_handler, NULL); - if (scm_is_integer(res)) { + if (scm_is_bool(res)) { *failure = NULL; - return scm_to_int(res); + return scm_to_bool(res); } else { *failure = scm_to_utf8_stringn(res, NULL); return 0; diff --git a/fig-utils/src/Fig/Utils/FFI.hs b/fig-utils/src/Fig/Utils/FFI.hs index b5ee80e..be5e612 100644 --- a/fig-utils/src/Fig/Utils/FFI.hs +++ b/fig-utils/src/Fig/Utils/FFI.hs @@ -9,8 +9,8 @@ import Foreign.Marshal.Alloc foreign import ccall "check_answer" c_check_answer :: Ptr CString -> CString -> CString -> IO Int -checkAnswer :: Text -> Text -> IO (Either Text Bool) -checkAnswer tcode tanswer = +checkAnswer :: MonadIO m => Text -> Text -> m (Either Text Bool) +checkAnswer tcode tanswer = liftIO $ withCString (unpack tcode) $ \code -> withCString (unpack tanswer) $ \answer -> alloca $ \rerr -> do |
