Skip to content

Commit

Permalink
Add example to probe purescript-refs C FFI
Browse files Browse the repository at this point in the history
  • Loading branch information
Lupino committed Oct 3, 2018
1 parent 927bece commit 5db737c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"purescript-console": "pure-c/purescript-console#master",
"purescript-control": "pure-c/purescript-control#master",
"purescript-effect": "pure-c/purescript-effect#master",
"purescript-math": "pure-c/purescript-math#master"
"purescript-math": "pure-c/purescript-math#master",
"purescript-refs": "pure-c/purescript-refs#master"
},
"resolutions": {
"purescript-effect": "master",
Expand Down
20 changes: 20 additions & 0 deletions examples/refs/Main.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module Main where

import Prelude

import Effect (Effect)
import Effect.Console as Console
import Effect.Ref as Ref

main :: Effect Unit
main = do
ref <- Ref.new "new"
run "Ref.new" =<< Ref.read ref
Ref.modify_ (const "modify_") ref
run "Ref.modify_" =<< Ref.read ref
Ref.write "write" ref
run "Ref.write" =<< Ref.read ref
where
run label result =
Console.log $
"[" <> label <> "]: " <> show result
14 changes: 14 additions & 0 deletions examples/refs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
default: main
.PHONY: default

PUREC_DIR := ../..
export PATH := $(PUREC_DIR)/node_modules/.bin:$(PATH)
include $(PUREC_DIR)/mk/target.mk

SHELL := /bin/bash
srcs := .
deps := $(shell\
find ../bower_components/purescript-{control,effect,prelude,console,refs}/src/\
-type f\
-name '*.purs')
$(eval $(call purs_mk_target,main,Main,$(srcs),$(deps)))
1 change: 1 addition & 0 deletions scripts/bower-depgraph
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ completed_ffi_for=(
purescript-effect
purescript-assert
purescript-math
purescript-refs
)

function has_completed_ffi {
Expand Down

0 comments on commit 5db737c

Please sign in to comment.