Skip to content

Instantly share code, notes, and snippets.

@natefaubion
Created August 15, 2014 16:46
Show Gist options
  • Save natefaubion/1e8a18eaf74e20ecc208 to your computer and use it in GitHub Desktop.
Save natefaubion/1e8a18eaf74e20ecc208 to your computer and use it in GitHub Desktop.
module Control.Global (importLib) where
foreign import importLib
"function importLib(node) {\
\ return function(global) {\
\ if (typeof require !== 'undefined' && typeof process !== 'undefined') {\
\ return require(node);\
\ } else {\
\ return window[global];\
\ }\
\ };\
\}" :: forall a. String -> String -> a
-- foreign import data Foo :: *
-- lib :: Foo
-- lib = importLib "foo" "foo"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment