Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle active region case better in haskell-process-show-type-at #701

Closed
geraldus opened this issue Jun 6, 2015 · 1 comment
Closed

Comments

@geraldus
Copy link
Contributor

geraldus commented Jun 6, 2015

The :type-at command works fine when you ask a type for several line, for example

main :: IO ()
main =
  do let x = "Hello, World!"
     putStrLn x

following command will infer type for region starts from do and ends at x on the next line:

λ> :type-at /Users/arthurfayzrakhmanov/Haskell/test/HelloWorld.hs 3 3 4 16
:: IO ()

and even without x:

λ> :type-at /Users/arthurfayzrakhmanov/Haskell/test/HelloWorld.hs 3 3 4 15
 :: String -> IO ()

The function show-type-at works fine and returns correct results in these cases (active region wrapping several lines), the only caveat is that currently it passes marked expression as fifth argument to type at command and it confuses REPL and brings errors:

Haskell presentation buffer contents:

do let x = "Hello, World!" :: String -> IO ()

<interactive>:50:6-13:
    No instance for (Show (String -> IO ()))
      arising from a use of print
    In a stmt of an interactive GHCi command: print it

Haskell process log contents:

-> :type-at /Users/arthurfayzrakhmanov/Haskell/test/HelloWorld.hs 3 3 4 14 do let x = "Hello, World!"
     putStrLn

<- do let x = "Hello, World!" :: String -> IO ()

   

   <interactive>:50:6-13:

       No instance for (Show (String -> IO ()))

         arising from a use of print

       In a stmt of an interactive GHCi command: print it

The fifth argument of :type-at is optional and plays auxiliary role:

λ> :type-at /Users/arthurfayzrakhmanov/Haskell/test/HelloWorld.hs 3 3 4 15 "TEST"
"TEST" :: String -> IO ()
λ> :type-at /Users/arthurfayzrakhmanov/Haskell/test/HelloWorld.hs 3 3 4 15 WHAT?
WHAT? :: String -> IO ()

So we have at least two options to make world better:

  • reduce expression using haskell-utils-reduce-string1 before pass it to :type-at command
  • reduce expression like haskell-mode-message-line2 does
  • replace multiline and long expressions with
  • replace long expressions with some arbitrary string, such as "expr".

Any thoughts?

@geraldus
Copy link
Contributor Author

geraldus commented Jun 7, 2015

Fixed in #703

@geraldus geraldus closed this as completed Jun 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant