{"action":"created","issue":{"url":"https://api.github.com/repos/purescript/purescript/issues/3251","repository_url":"https://api.github.com/repos/purescript/purescript","labels_url":"https://api.github.com/repos/purescript/purescript/issues/3251/labels{/name}","comments_url":"https://api.github.com/repos/purescript/purescript/issues/3251/comments","events_url":"https://api.github.com/repos/purescript/purescript/issues/3251/events","html_url":"https://github.com/purescript/purescript/issues/3251","id":299934201,"number":3251,"title":"Something like Warn for managing NPM dependencies","user":{"login":"safareli","id":1932383,"avatar_url":"https://avatars1.githubusercontent.com/u/1932383?v=4","gravatar_id":"","url":"https://api.github.com/users/safareli","html_url":"https://github.com/safareli","followers_url":"https://api.github.com/users/safareli/followers","following_url":"https://api.github.com/users/safareli/following{/other_user}","gists_url":"https://api.github.com/users/safareli/gists{/gist_id}","starred_url":"https://api.github.com/users/safareli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/safareli/subscriptions","organizations_url":"https://api.github.com/users/safareli/orgs","repos_url":"https://api.github.com/users/safareli/repos","events_url":"https://api.github.com/users/safareli/events{/privacy}","received_events_url":"https://api.github.com/users/safareli/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-24T11:26:02Z","updated_at":"2018-02-24T11:45:48Z","closed_at":null,"author_association":"NONE","body":"Let's say we have special type class like Warn which allows to declare module and it's version, which  is needed to run some function.\r\n\r\n``` purs\r\nclass NPMDeps (a :: # Symbol)\r\ninstance warnNPM :: Warn \"npm.dependencies = [TODO generate staff from a]\" => NPMDeps a\r\n```\r\n\r\nFor example this is [FFI part](https://github.com/sharkdp/purescript-bigints/blob/master/src/Data/BigInt.js#L3-L29) of \"big-integer\" wrapper (by @sharkdp). as you can see only `fromBase'`, `fromInt` and `fromNumber` depend on `require(\"big-integer\")`. And they are \"imported\" in purescript like this:\r\n\r\n``` purs\r\nforeign import fromBase' :: forall a. (a -> Maybe a) -> Maybe a -> Int -> String -> Maybe BigInt\r\nforeign import fromInt :: Int -> BigInt\r\nforeign import fromNumber :: Number -> BigInt\r\n```\r\n\r\nInstead if we have something like the `NPMDeps` class, we could do:\r\n\r\n``` purs\r\ntype WithDeps a = NPMDeps (\"big-integer\" :: \"1.2.x\") => a\r\n\r\nforeign import fromBase' :: forall a. WithDeps ((a -> Maybe a) -> Maybe a -> Int -> String -> Maybe BigInt)\r\nforeign import fromInt :: WithDeps (Int -> BigInt)\r\nforeign import fromNumber :: WithDeps (Number -> BigInt)\r\n```\r\n\r\nAnd during build, such \"warnings\" will be accumulated and used to make sure correct versions of deps are present in `{package,yarn, ... }.json`. \r\nI think we don't need this deps for such FII functions which invoke a method on already existing instances, as it means there is already the dependency in runtime. We need this \"warnings\" when the function explicitly depends on `require`.\r\n\r\nCame up with this based on [from my recent tweets](https://twitter.com/safareli/status/967344782627561475)"},"comment":{"url":"https://api.github.com/repos/purescript/purescript/issues/comments/368222851","html_url":"https://github.com/purescript/purescript/issues/3251#issuecomment-368222851","issue_url":"https://api.github.com/repos/purescript/purescript/issues/3251","id":368222851,"user":{"login":"safareli","id":1932383,"avatar_url":"https://avatars1.githubusercontent.com/u/1932383?v=4","gravatar_id":"","url":"https://api.github.com/users/safareli","html_url":"https://github.com/safareli","followers_url":"https://api.github.com/users/safareli/followers","following_url":"https://api.github.com/users/safareli/following{/other_user}","gists_url":"https://api.github.com/users/safareli/gists{/gist_id}","starred_url":"https://api.github.com/users/safareli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/safareli/subscriptions","organizations_url":"https://api.github.com/users/safareli/orgs","repos_url":"https://api.github.com/users/safareli/repos","events_url":"https://api.github.com/users/safareli/events{/privacy}","received_events_url":"https://api.github.com/users/safareli/received_events","type":"User","site_admin":false},"created_at":"2018-02-24T11:45:48Z","updated_at":"2018-02-24T11:45:48Z","author_association":"NONE","body":"I think it could be done with Just `Warn` class and special support for this warnings in purescript-ide (so in editor you don' get usual warnings for it), and in purescript-psa or some different lib on top of ps-psa. \r\n\r\nI think something like this will have huge benefits for app developers as you would have much better guaranties and information on what you depend on.  for example, if we have some lib which looks like this:\r\n\r\n``` purs\r\nforeign import foo :: NPMDeps (\"foo\" :: \"1.x.x\") => String -> String\r\nforeign import bar :: NPMDeps (\"bar\" :: \"2.x.x\") => String -> String\r\n```\r\n\r\nAnd the app only uses bar you would get warning for module bar only so you would be sure that you can only install bar and app will work just fine.\r\n\r\n\r\nI opened this issue here to get feedback on the idea, and possible implementation directions.\r\n"}}
{"actor":{"display_login":"safareli"}}