-
Couldn't load subscription status.
- Fork 349
Description
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 xfollowing 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 itHaskell 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 itThe 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-atcommand - 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?