All Projects → eeue56 → Elm Ffi

eeue56 / Elm Ffi

Licence: bsd-3-clause
An FFI interface for Elm

Programming Languages

javascript
184084 projects - #8 most used programming language
elm
856 projects

Labels

Projects that are alternatives of or similar to Elm Ffi

Savannakit
A high-performance, protocol oriented, framework for creating native IDEs for iOS and macOS, written in Swift
Stars: ✭ 816 (+1532%)
Mutual labels:  native
Ti.splashview
💦 Support for the splash-screen library CBZSplashView in Appcelerator Titanium.
Stars: ✭ 20 (-60%)
Mutual labels:  native
Ti.flurry
The Flurry Analytics Module for Appcelerator Titanium
Stars: ✭ 37 (-26%)
Mutual labels:  native
React Native Geolocation Service
React native geolocation service for iOS and android
Stars: ✭ 934 (+1768%)
Mutual labels:  native
Originr
Species origin data from the web in R
Stars: ✭ 13 (-74%)
Mutual labels:  native
Nativeleakdetector
Win32 memory leak detector with ETW
Stars: ✭ 30 (-40%)
Mutual labels:  native
Delphimvcframework
DMVCFramework (for short) is a popular and powerful framework for web solution in Delphi. Supports RESTful and JSON-RPC APIs development.
Stars: ✭ 761 (+1422%)
Mutual labels:  native
Actor4j Core
Actor4j is an actor-oriented Java framework. Useful for building lightweighted microservices (these are the actors themselves or groups of them). Enhanced performance of message passing.
Stars: ✭ 48 (-4%)
Mutual labels:  native
Fake Jni
An implementation of the JNI and JVMTI with support for direct interaction between natively registered classes and JVM objects.
Stars: ✭ 20 (-60%)
Mutual labels:  native
Titanium Identity
A collection of API's to authenticate with your device: Keychain/Keystore, Touch ID and Face ID
Stars: ✭ 36 (-28%)
Mutual labels:  native
Ti.urlsession
Use the NSURLSession API to download and upload files in Titanium.
Stars: ✭ 7 (-86%)
Mutual labels:  native
Native Windows Gui
A light windows GUI toolkit for rust
Stars: ✭ 872 (+1644%)
Mutual labels:  native
Redzone
Lightweight C++ template engine with Jinja2-like syntax
Stars: ✭ 30 (-40%)
Mutual labels:  native
Xtd forms
Modern c++17 library to create native gui for Microsoft Windows, Apple macOS and Linux.
Stars: ✭ 25 (-50%)
Mutual labels:  native
Spalert
Native alert from Apple Music & Feedback. Contains Done, Heart & Message and other presets.
Stars: ✭ 1,014 (+1928%)
Mutual labels:  native
Slim.js
Fast & Robust Front-End Micro-framework based on modern standards
Stars: ✭ 789 (+1478%)
Mutual labels:  native
Imgui
Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
Stars: ✭ 33,574 (+67048%)
Mutual labels:  native
Sanic.js
JS Gotta go fast ! | Increase native JS functions performances
Stars: ✭ 50 (+0%)
Mutual labels:  native
Fennel Nvim
running fennel-lang natively in neovim
Stars: ✭ 44 (-12%)
Mutual labels:  native
Revery
⚡ Native, high-performance, cross-platform desktop apps - built with Reason!
Stars: ✭ 7,812 (+15524%)
Mutual labels:  native

elm-ffi

A FFI interface for Elm

🔥 ‼️ This library is intended for as a reference for experienced Elm developers only, and it's not even for them! If you haven't written a lot of Elm and end up here, try asking about your problem on Slack instead! ‼️ 🔥 This package is intended for experimentation only and may break everything at any time.

🔥 Both sync and async functions can introduce runtime errors in Elm and break everything. safeAsync and safeSync can be used more safely, as they wrap each call in try..catch and return a result. Note, if safeAsync's code fails during callback evaluation, it will not be returned as a result and will cause runtime errors. Because of this, this library should only really be used for prototyping ideas. This is not a production quality library. 🔥

Sync

Imagine you want to define your own logging function, but don't want the wrapper from Debug.log.

With this library, you can do the following:

import FFI

log : a -> ()
log thing =
    FFI.sync "console.log(_0);" [ FFI.asIs thing ]
        |> (\_ -> ())

which can then be used like this:

someFunction =
    let 
        _ = log "Some thing is being called!"
    in 
        5

Each argument is applied in order of the list of arguments given - so _0 is the first argument, then _1 is the second and so on.

In order to ensure that the code works okay, ensure that any function you make takes each argument seperately. Otherwise, the functions no longer work properly with partial application.

Note that safeSync exists in order to allow for safer creation of runtime functions, by instead returning a Result. For example:

safeLog : a -> ()
safeLog thing = 
    case FFI.safeSync "console.log(_0);" [ FFI.asIs thing ] of 
        Err message ->
            let
                _ = Debug.log "FFI log function did not work!" message
            in 
                ()
        Ok v ->
            ()

Async

Imagine you want to return a value after a certain amount of time. You'd write

import FFI

returnAfterX : Int -> Value -> Task String Value
returnAfterX time value =
    FFI.async """
setTimeout(function(){
    callback(_succeed(_1))
}, _0)
"""
    [ Json.Encode.int time, value ]

Now you can use this as you would any other task. _fail can be used to produce the error task, while _succeed is for success cases. You have to wrap this value in a call to callback - which is used to tell the scheduler that the task has completed.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].