Created
October 2, 2016 11:14
-
-
Save afcondon/c683df7933e97a642c246387a4af4b64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Prelude (Unit) | |
import Control.Monad.Eff (Eff) | |
import Control.Monad.Eff.Console (CONSOLE, log) | |
import Data.Function.Eff (EffFn4, EffFn3, mkEffFn4, runEffFn3) | |
foreign import data D3 :: ! | |
foreign import data Selection :: * -> * | |
foreign import data D3Element :: * | |
type PredicateFn d x = ∀ eff. (d -> Number -> (Array D3Element) -> D3Element -> Eff (d3::D3|eff) x) | |
data AttrSetter d x = SetAttr x | |
| AttrFn (PredicateFn d x) -- rename both data ctor and Type here TODO | |
foreign import attrFn :: ∀ d v eff. EffFn3 (d3::D3|eff) String v (Selection d) (Selection d) | |
foreign import attrFnP :: ∀ d x eff. EffFn3 (d3::D3|eff) -- eff of attrFnP | |
String -- 1st arg of attrFnP | |
(EffFn4 (d3::D3|eff) -- eff of callback (callback is 2nd arg of fn) | |
d -- 1st arg of callback | |
Number -- 2nd arg of callback | |
(Array D3Element) -- 3rd arg of callback | |
D3Element -- 4th arg of callback | |
x) -- result of callback, what the attr is to be set to | |
(Selection d) -- 3rd arg of attrFnP | |
(Selection d) -- result of attrFnP | |
attr :: ∀ d x eff. String -> AttrSetter d x -> Selection d -> Eff (d3::D3|eff) (Selection d) | |
attr s (SetAttr x) = runEffFn3 attrFn s x | |
attr s (AttrFn p) = runEffFn3 attrFnP s (mkEffFn4 p) | |
main :: forall e. Eff (console :: CONSOLE | e) Unit | |
main = do | |
log "Hello sailor!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very weird, code above compiles but in more meaty example line 32 (mkEffFn4 p) fails as follows:
Link to source line of that error in the purescript-d3v4 repo:
https://github.com/afcondon/purescript-d3v4/blob/newstart/src/Selection.purs#L117