{"action":"created","comment":{"url":"https://api.github.com/repos/erdeszt/purescript/pulls/comments/37701666","id":37701666,"diff_hunk":"@@ -0,0 +1,314 @@\n+{-# LANGUAGE TupleSections #-}\n+{-# LANGUAGE OverloadedStrings #-}\n+{-# LANGUAGE GeneralizedNewtypeDeriving #-}\n+{-# LANGUAGE RecordWildCards #-}\n+\n+module Script where\n+\n+import Control.Arrow (first)\n+import Control.Monad\n+import Control.Monad.IO.Class\n+import Control.Monad.Error\n+import Control.Monad.Trans.Maybe (MaybeT(..), runMaybeT)\n+import Control.Monad.Trans.State.Strict\n+import qualified Data.Map as Map\n+import Data.Foldable (traverse_)\n+import Data.Tuple (swap)\n+import Text.Parsec\n+import Language.PureScript.Parser\n+import qualified Language.PureScript as P\n+import qualified Data.Map as M\n+import System.FilePath (pathSeparator)\n+import System.IO.Error (tryIOError)\n+import System.IO.Unsafe (unsafePerformIO)\n+import System.Directory\n+import System.Process (readProcessWithExitCode)\n+import System.FilePath (FilePath, (</>))\n+import System.FilePath.Glob (glob)\n+import System.Exit\n+\n+{-\n+\n+  TODO (Type under cursor):\n+\n+    - Figure out how to typecheck and expression\n+    -- Document the current code\n+\n+    - Lex the file\n+    - Get the position closest to the requested\n+    - Parse expression\n+    - Type check\n+    - Return type && $$$\n+\n+-}\n+\n+-- \"Interactive\"\n+inputFiles = [\"bower_components/purescript-*/**/*.purs\"]\n+inputFiles' = unsafePerformIO (concat <$> mapM glob inputFiles)\n+{-# NOINLINE inputFiles' #-}\n+inputForeignFiles = [\"bower_components/purescript-*/**/*.js\"]\n+inputForeignFiles' = unsafePerformIO (concat <$> mapM glob inputForeignFiles)\n+-- Running psci in ghci:\n+-- loop $ PSCiOptions False inputFiles inputForeignFiles []\n+(Right lexedAdd) = P.lex \"\" \"1+1\"\n+(Right parsedAdd) = P.runTokenParser \"\" (psciExpression <* eof) lexedAdd\n+(Right loadedModules) = unsafePerformIO (loadAllModules inputFiles')\n+{-# NOINLINE loadedModules #-}\n+loadedModuleNames = map (\\(_, P.Module _ _ n _ _) -> n) loadedModules\n+module' = createTemporaryModule True defaultPSCModState parsedAdd\n+\n+made = runMake $ make defaultPSCModState [(Left P.RebuildAlways, supportModule), (Left P.RebuildAlways, module')]\n+\n+foreignMade = unsafePerformIO $ runMake $ do\n+  foreignFilesContent <- forM inputForeignFiles' (\\inFile -> (inFile,) <$> makeIO (const (P.SimpleErrorWrapper $ P.CannotReadFile inFile)) (readFile inFile))\n+  P.parseForeignModulesFromFiles foreignFilesContent\n+{-# NOINLINE foreignMade #-}\n+(Right foreignMade') = foreignMade\n+\n+evalExpr :: String -> [String] -> [String] -> IO ()\n+evalExpr expr inputFiles inputForeignFiles = do","path":"psc-mod/Script.hs","position":69,"original_position":69,"commit_id":"fa9026b470cfca3cd09e23e60e72ab5b57a29b8c","original_commit_id":"fa9026b470cfca3cd09e23e60e72ab5b57a29b8c","user":{"login":"erdeszt","id":1301484,"avatar_url":"https://avatars.githubusercontent.com/u/1301484?v=3","gravatar_id":"","url":"https://api.github.com/users/erdeszt","html_url":"https://github.com/erdeszt","followers_url":"https://api.github.com/users/erdeszt/followers","following_url":"https://api.github.com/users/erdeszt/following{/other_user}","gists_url":"https://api.github.com/users/erdeszt/gists{/gist_id}","starred_url":"https://api.github.com/users/erdeszt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erdeszt/subscriptions","organizations_url":"https://api.github.com/users/erdeszt/orgs","repos_url":"https://api.github.com/users/erdeszt/repos","events_url":"https://api.github.com/users/erdeszt/events{/privacy}","received_events_url":"https://api.github.com/users/erdeszt/received_events","type":"User","site_admin":false},"body":"Split to ```setupState :: [String] -> [String] -> PSCModState``` and ```evalExpr :: PSCModState -> String -> IO ()```","created_at":"2015-08-23T01:34:30Z","updated_at":"2015-08-23T01:34:30Z","html_url":"https://github.com/erdeszt/purescript/pull/2#discussion_r37701666","pull_request_url":"https://api.github.com/repos/erdeszt/purescript/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/erdeszt/purescript/pulls/comments/37701666"},"html":{"href":"https://github.com/erdeszt/purescript/pull/2#discussion_r37701666"},"pull_request":{"href":"https://api.github.com/repos/erdeszt/purescript/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/erdeszt/purescript/pulls/2","id":43113163,"html_url":"https://github.com/erdeszt/purescript/pull/2","diff_url":"https://github.com/erdeszt/purescript/pull/2.diff","patch_url":"https://github.com/erdeszt/purescript/pull/2.patch","issue_url":"https://api.github.com/repos/erdeszt/purescript/issues/2","number":2,"state":"open","locked":false,"title":"Psc mod new","user":{"login":"erdeszt","id":1301484,"avatar_url":"https://avatars.githubusercontent.com/u/1301484?v=3","gravatar_id":"","url":"https://api.github.com/users/erdeszt","html_url":"https://github.com/erdeszt","followers_url":"https://api.github.com/users/erdeszt/followers","following_url":"https://api.github.com/users/erdeszt/following{/other_user}","gists_url":"https://api.github.com/users/erdeszt/gists{/gist_id}","starred_url":"https://api.github.com/users/erdeszt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erdeszt/subscriptions","organizations_url":"https://api.github.com/users/erdeszt/orgs","repos_url":"https://api.github.com/users/erdeszt/repos","events_url":"https://api.github.com/users/erdeszt/events{/privacy}","received_events_url":"https://api.github.com/users/erdeszt/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-08-23T00:44:58Z","updated_at":"2015-08-23T01:34:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"731c86918ab97243ee24004ba9112cf5c8fd0153","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/erdeszt/purescript/pulls/2/commits","review_comments_url":"https://api.github.com/repos/erdeszt/purescript/pulls/2/comments","review_comment_url":"https://api.github.com/repos/erdeszt/purescript/pulls/comments{/number}","comments_url":"https://api.github.com/repos/erdeszt/purescript/issues/2/comments","statuses_url":"https://api.github.com/repos/erdeszt/purescript/statuses/fa9026b470cfca3cd09e23e60e72ab5b57a29b8c","head":{"label":"erdeszt:psc-mod-new","ref":"psc-mod-new","sha":"fa9026b470cfca3cd09e23e60e72ab5b57a29b8c","user":{"login":"erdeszt","id":1301484,"avatar_url":"https://avatars.githubusercontent.com/u/1301484?v=3","gravatar_id":"","url":"https://api.github.com/users/erdeszt","html_url":"https://github.com/erdeszt","followers_url":"https://api.github.com/users/erdeszt/followers","following_url":"https://api.github.com/users/erdeszt/following{/other_user}","gists_url":"https://api.github.com/users/erdeszt/gists{/gist_id}","starred_url":"https://api.github.com/users/erdeszt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erdeszt/subscriptions","organizations_url":"https://api.github.com/users/erdeszt/orgs","repos_url":"https://api.github.com/users/erdeszt/repos","events_url":"https://api.github.com/users/erdeszt/events{/privacy}","received_events_url":"https://api.github.com/users/erdeszt/received_events","type":"User","site_admin":false},"repo":{"id":40416638,"name":"purescript","full_name":"erdeszt/purescript","owner":{"login":"erdeszt","id":1301484,"avatar_url":"https://avatars.githubusercontent.com/u/1301484?v=3","gravatar_id":"","url":"https://api.github.com/users/erdeszt","html_url":"https://github.com/erdeszt","followers_url":"https://api.github.com/users/erdeszt/followers","following_url":"https://api.github.com/users/erdeszt/following{/other_user}","gists_url":"https://api.github.com/users/erdeszt/gists{/gist_id}","starred_url":"https://api.github.com/users/erdeszt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erdeszt/subscriptions","organizations_url":"https://api.github.com/users/erdeszt/orgs","repos_url":"https://api.github.com/users/erdeszt/repos","events_url":"https://api.github.com/users/erdeszt/events{/privacy}","received_events_url":"https://api.github.com/users/erdeszt/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/erdeszt/purescript","description":"A small strongly typed language that compiles to Javascript","fork":true,"url":"https://api.github.com/repos/erdeszt/purescript","forks_url":"https://api.github.com/repos/erdeszt/purescript/forks","keys_url":"https://api.github.com/repos/erdeszt/purescript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/erdeszt/purescript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/erdeszt/purescript/teams","hooks_url":"https://api.github.com/repos/erdeszt/purescript/hooks","issue_events_url":"https://api.github.com/repos/erdeszt/purescript/issues/events{/number}","events_url":"https://api.github.com/repos/erdeszt/purescript/events","assignees_url":"https://api.github.com/repos/erdeszt/purescript/assignees{/user}","branches_url":"https://api.github.com/repos/erdeszt/purescript/branches{/branch}","tags_url":"https://api.github.com/repos/erdeszt/purescript/tags","blobs_url":"https://api.github.com/repos/erdeszt/purescript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/erdeszt/purescript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/erdeszt/purescript/git/refs{/sha}","trees_url":"https://api.github.com/repos/erdeszt/purescript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/erdeszt/purescript/statuses/{sha}","languages_url":"https://api.github.com/repos/erdeszt/purescript/languages","stargazers_url":"https://api.github.com/repos/erdeszt/purescript/stargazers","contributors_url":"https://api.github.com/repos/erdeszt/purescript/contributors","subscribers_url":"https://api.github.com/repos/erdeszt/purescript/subscribers","subscription_url":"https://api.github.com/repos/erdeszt/purescript/subscription","commits_url":"https://api.github.com/repos/erdeszt/purescript/commits{/sha}","git_commits_url":"https://api.github.com/repos/erdeszt/purescript/git/commits{/sha}","comments_url":"https://api.github.com/repos/erdeszt/purescript/comments{/number}","issue_comment_url":"https://api.github.com/repos/erdeszt/purescript/issues/comments{/number}","contents_url":"https://api.github.com/repos/erdeszt/purescript/contents/{+path}","compare_url":"https://api.github.com/repos/erdeszt/purescript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/erdeszt/purescript/merges","archive_url":"https://api.github.com/repos/erdeszt/purescript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/erdeszt/purescript/downloads","issues_url":"https://api.github.com/repos/erdeszt/purescript/issues{/number}","pulls_url":"https://api.github.com/repos/erdeszt/purescript/pulls{/number}","milestones_url":"https://api.github.com/repos/erdeszt/purescript/milestones{/number}","notifications_url":"https://api.github.com/repos/erdeszt/purescript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/erdeszt/purescript/labels{/name}","releases_url":"https://api.github.com/repos/erdeszt/purescript/releases{/id}","created_at":"2015-08-08T21:14:46Z","updated_at":"2015-08-08T21:14:46Z","pushed_at":"2015-08-23T00:44:58Z","git_url":"git://github.com/erdeszt/purescript.git","ssh_url":"git@github.com:erdeszt/purescript.git","clone_url":"https://github.com/erdeszt/purescript.git","svn_url":"https://github.com/erdeszt/purescript","homepage":"http://purescript.org","size":4736,"stargazers_count":0,"watchers_count":0,"language":"Haskell","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"erdeszt:master","ref":"master","sha":"7e8e8ca83bbc36dcdbf35c2be1eb25eba7b37bc8","user":{"login":"erdeszt","id":1301484,"avatar_url":"https://avatars.githubusercontent.com/u/1301484?v=3","gravatar_id":"","url":"https://api.github.com/users/erdeszt","html_url":"https://github.com/erdeszt","followers_url":"https://api.github.com/users/erdeszt/followers","following_url":"https://api.github.com/users/erdeszt/following{/other_user}","gists_url":"https://api.github.com/users/erdeszt/gists{/gist_id}","starred_url":"https://api.github.com/users/erdeszt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erdeszt/subscriptions","organizations_url":"https://api.github.com/users/erdeszt/orgs","repos_url":"https://api.github.com/users/erdeszt/repos","events_url":"https://api.github.com/users/erdeszt/events{/privacy}","received_events_url":"https://api.github.com/users/erdeszt/received_events","type":"User","site_admin":false},"repo":{"id":40416638,"name":"purescript","full_name":"erdeszt/purescript","owner":{"login":"erdeszt","id":1301484,"avatar_url":"https://avatars.githubusercontent.com/u/1301484?v=3","gravatar_id":"","url":"https://api.github.com/users/erdeszt","html_url":"https://github.com/erdeszt","followers_url":"https://api.github.com/users/erdeszt/followers","following_url":"https://api.github.com/users/erdeszt/following{/other_user}","gists_url":"https://api.github.com/users/erdeszt/gists{/gist_id}","starred_url":"https://api.github.com/users/erdeszt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erdeszt/subscriptions","organizations_url":"https://api.github.com/users/erdeszt/orgs","repos_url":"https://api.github.com/users/erdeszt/repos","events_url":"https://api.github.com/users/erdeszt/events{/privacy}","received_events_url":"https://api.github.com/users/erdeszt/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/erdeszt/purescript","description":"A small strongly typed language that compiles to Javascript","fork":true,"url":"https://api.github.com/repos/erdeszt/purescript","forks_url":"https://api.github.com/repos/erdeszt/purescript/forks","keys_url":"https://api.github.com/repos/erdeszt/purescript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/erdeszt/purescript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/erdeszt/purescript/teams","hooks_url":"https://api.github.com/repos/erdeszt/purescript/hooks","issue_events_url":"https://api.github.com/repos/erdeszt/purescript/issues/events{/number}","events_url":"https://api.github.com/repos/erdeszt/purescript/events","assignees_url":"https://api.github.com/repos/erdeszt/purescript/assignees{/user}","branches_url":"https://api.github.com/repos/erdeszt/purescript/branches{/branch}","tags_url":"https://api.github.com/repos/erdeszt/purescript/tags","blobs_url":"https://api.github.com/repos/erdeszt/purescript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/erdeszt/purescript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/erdeszt/purescript/git/refs{/sha}","trees_url":"https://api.github.com/repos/erdeszt/purescript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/erdeszt/purescript/statuses/{sha}","languages_url":"https://api.github.com/repos/erdeszt/purescript/languages","stargazers_url":"https://api.github.com/repos/erdeszt/purescript/stargazers","contributors_url":"https://api.github.com/repos/erdeszt/purescript/contributors","subscribers_url":"https://api.github.com/repos/erdeszt/purescript/subscribers","subscription_url":"https://api.github.com/repos/erdeszt/purescript/subscription","commits_url":"https://api.github.com/repos/erdeszt/purescript/commits{/sha}","git_commits_url":"https://api.github.com/repos/erdeszt/purescript/git/commits{/sha}","comments_url":"https://api.github.com/repos/erdeszt/purescript/comments{/number}","issue_comment_url":"https://api.github.com/repos/erdeszt/purescript/issues/comments{/number}","contents_url":"https://api.github.com/repos/erdeszt/purescript/contents/{+path}","compare_url":"https://api.github.com/repos/erdeszt/purescript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/erdeszt/purescript/merges","archive_url":"https://api.github.com/repos/erdeszt/purescript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/erdeszt/purescript/downloads","issues_url":"https://api.github.com/repos/erdeszt/purescript/issues{/number}","pulls_url":"https://api.github.com/repos/erdeszt/purescript/pulls{/number}","milestones_url":"https://api.github.com/repos/erdeszt/purescript/milestones{/number}","notifications_url":"https://api.github.com/repos/erdeszt/purescript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/erdeszt/purescript/labels{/name}","releases_url":"https://api.github.com/repos/erdeszt/purescript/releases{/id}","created_at":"2015-08-08T21:14:46Z","updated_at":"2015-08-08T21:14:46Z","pushed_at":"2015-08-23T00:44:58Z","git_url":"git://github.com/erdeszt/purescript.git","ssh_url":"git@github.com:erdeszt/purescript.git","clone_url":"https://github.com/erdeszt/purescript.git","svn_url":"https://github.com/erdeszt/purescript","homepage":"http://purescript.org","size":4736,"stargazers_count":0,"watchers_count":0,"language":"Haskell","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/erdeszt/purescript/pulls/2"},"html":{"href":"https://github.com/erdeszt/purescript/pull/2"},"issue":{"href":"https://api.github.com/repos/erdeszt/purescript/issues/2"},"comments":{"href":"https://api.github.com/repos/erdeszt/purescript/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/erdeszt/purescript/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/erdeszt/purescript/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/erdeszt/purescript/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/erdeszt/purescript/statuses/fa9026b470cfca3cd09e23e60e72ab5b57a29b8c"}}}}