29 Oct 22:36 2013

29 Oct 23:06 2013

### Re: Getting types inside a function in ghci

Christopher Done <chrisdone <at> gmail.com>

2013-10-29 22:06:08 GMT

2013-10-29 22:06:08 GMT

On 29 October 2013 22:36, martin <martin.drautzburg <at> web.de> wrote:

is there a way to determine types of symbols which are not toplevel but inside a function?

Not at present without transformation. There are two reasonably reliable approaches:

Insert noisy holes/make intentional type errors: http://ghc.haskell.org/trac/ghc/wiki/Holes#Insertingdeliberatetypeerrors

Insert noisy holes/make intentional type errors: http://ghc.haskell.org/trac/ghc/wiki/Holes#Insertingdeliberatetypeerrors

Holes will land in GHC to support this explicitly. I don't know what version of GHC has/will have this.

Alternatively, you can use ghc-mod (https://github.com/kazu-yamamoto/ghc-mod) which, if you can get it to work, can tell you the types of sub-expressions.

Lastly, the next version of the FP Complete IDE gives you types of sub-expressions just by clicking on them or selecting them out of the box.

_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe <at> haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

29 Oct 23:34 2013

### Re: Getting types inside a function in ghci

martin <martin.drautzburg <at> web.de>

2013-10-29 22:34:21 GMT

2013-10-29 22:34:21 GMT

Am 10/29/2013 11:06 PM, schrieb Christopher Done: > On 29 October 2013 22:36, martin <martin.drautzburg <at> web.de <mailto:martin.drautzburg <at> web.de>> wrote: > > is there a way to determine types of symbols which are not toplevel but inside a function? > > > Not at present without transformation. There are two reasonably reliable approaches: > > Insert noisy holes/make intentional type errors: http://ghc.haskell.org/trac/ghc/wiki/Holes#Insertingdeliberatetypeerrors > > Implicit parameters: http://ghc.haskell.org/trac/ghc/wiki/Holes#Implicitparameters > > Holes will land in GHC to support this explicitly. I don't know what version of GHC has/will have this. > > Alternatively, you can use ghc-mod (https://github.com/kazu-yamamoto/ghc-mod) which, if you can get it to work, can tell > you the types of sub-expressions. > > Lastly, the next version of the FP Complete IDE gives you types of sub-expressions just by clicking on them or selecting > them out of the box. Thanks, that helps. Related questions: how can I figure out the type (using holes) for the symbol left of the <- in a do expression? I mean other than: main = do x <- getChar::undefined return () Couldn't match type `undefined' with `IO Char' And how about plain lambdas. This works f = \x -> (x::undefined)+1 Couldn't match type `t' with `undefined' but what if x does not appear on the right side?

29 Oct 23:58 2013

### Re: Getting types inside a function in ghci

Christopher Done <chrisdone <at> gmail.com>

2013-10-29 22:58:17 GMT

2013-10-29 22:58:17 GMT

On the left of <- you could do

do () <- someThing

….

so that you'll get a type error against (). Or use scoped type variables:do () <- someThing

….

do (x::()) <- someThing

_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe <at> haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

30 Oct 04:25 2013

### Re: Getting types inside a function in ghci

Tom Murphy <amindfv <at> gmail.com>

2013-10-30 03:25:48 GMT

2013-10-30 03:25:48 GMT

FWIW, I asked about this on stackoverflow a while back, and there were a couple of good approaches, although nothing that completely achieves it from ghci. I've used the ghci breakpoint trick a few times, although it's doesn't give the "complete" type.

Here's the link:http://stackoverflow.com/questions/15034392/find-inferred-type-for-local-function

On Tue, Oct 29, 2013 at 3:06 PM, Christopher Done <chrisdone <at> gmail.com> wrote:

On 29 October 2013 22:36, martin <martin.drautzburg <at> web.de> wrote:is there a way to determine types of symbols which are not toplevel but inside a function?

Not at present without transformation. There are two reasonably reliable approaches:

Insert noisy holes/make intentional type errors: http://ghc.haskell.org/trac/ghc/wiki/Holes#Insertingdeliberatetypeerrors

Holes will land in GHC to support this explicitly. I don't know what version of GHC has/will have this.

Alternatively, you can use ghc-mod (https://github.com/kazu-yamamoto/ghc-mod) which, if you can get it to work, can tell you the types of sub-expressions.

Lastly, the next version of the FP Complete IDE gives you types of sub-expressions just by clicking on them or selecting them out of the box.

_______________________________________________

Haskell-Cafe mailing list

Haskell-Cafe <at> haskell.org

http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe <at> haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe