Skip to content

Instantly share code, notes, and snippets.

@dysinger
Last active August 29, 2015 13:56
Show Gist options
  • Save dysinger/9300540 to your computer and use it in GitHub Desktop.
Save dysinger/9300540 to your computer and use it in GitHub Desktop.
Some Errors with the Idris JS Codegen? Am I doing it wrong?
module Main
data Cloud : Type where
AWS : Ptr -> Cloud
data Service : Type where
S3 : Ptr -> Service
amazonCloud : IO Cloud
amazonCloud = mkForeign (FFun "require('aws-sdk');" [] FPtr) >>= return . AWS
s3Service : Cloud -> IO Service
s3Service (AWS p) =
mkForeign (FFun "new %0.S3();" [FPtr] FPtr) p >>= return . S3
------------------------^ breaks "__var_0 is not defined"
-- Having problems with Idris 'node' codegen on master from github.
-- The examples given in code in idris-dev (lib/javascript) and also
-- in tutorial pdf (%0 & %1 variable substitution) don't seem to work
-- on the latest idris. The above the variable __var_0 is undefined in
-- the generated javascript.
s3ListBuckets : Service -> IO ()
s3ListBuckets (S3 p) =
mkForeign (FFun "%0.listBuckets({}, function(_e,_d) {});" [FPtr] FUnit) p
-- Same problem happens here ^
main : IO ()
main = amazonCloud >>= s3Service >>= s3ListBuckets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment