Martin Hilbig | 21 Dec 00:35 2012
Picon

Hint's setImports usage

hi,

how to use Language.Haskell.Interpreter.setImports?

i use it like:

   setImports ["My.Module"]

so that my interpreted modules don't need to:

   import My.Module

But i still get:

   Not in scope: data constructor `MyType'

What am i doing wrong?

Thanks in advance.

have fun
martin
Michael Sloan | 21 Dec 00:55 2012
Picon

Re: Hint's setImports usage

Hello!

Try doing this first:

  loadModules ["My.Module"]

You may also need to set the "searchPath" - it defaults to the current director.  Another good function to know about is "setTopLevelModules", which is just like using ":load" in ghci - it imports everything in the module, including its imports.  So, I often do:

  loadModules ["MyPrelude"]
  setTopLevelModules ["MyPrelude"]

And stick all of the things that I want to be in scope into "MyPrelude.hs".

-Michael


On Thu, Dec 20, 2012 at 3:35 PM, Martin Hilbig <lists <at> mhilbig.de> wrote:
hi,

how to use Language.Haskell.Interpreter.setImports?

i use it like:

  setImports ["My.Module"]

so that my interpreted modules don't need to:

  import My.Module

But i still get:

  Not in scope: data constructor `MyType'

What am i doing wrong?

Thanks in advance.

have fun
martin

_______________________________________________
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
Martin Hilbig | 21 Dec 01:12 2012
Picon

Re: Hint's setImports usage

oh that's neat!

but what to do if MyPrelude is provided by some package?

i get this error:

   module `MyPrelude' is a package module

and neither

   set [languageExtensions := [PackageImports]]

nor

   {-# LANGUAGE PackageImports #-}

helps.

have fun
martin

On 21.12.2012 00:55, Michael Sloan wrote:
> Hello!
>
> Try doing this first:
>
>    loadModules ["My.Module"]
>
> You may also need to set the "searchPath" - it defaults to the current
> director.  Another good function to know about is "setTopLevelModules",
> which is just like using ":load" in ghci - it imports everything in the
> module, including its imports.  So, I often do:
>
>    loadModules ["MyPrelude"]
>    setTopLevelModules ["MyPrelude"]
>
> And stick all of the things that I want to be in scope into "MyPrelude.hs".
>
> -Michael
>
>
> On Thu, Dec 20, 2012 at 3:35 PM, Martin Hilbig <lists <at> mhilbig.de
> <mailto:lists <at> mhilbig.de>> wrote:
>
>     hi,
>
>     how to use Language.Haskell.Interpreter.__setImports?
>
>     i use it like:
>
>        setImports ["My.Module"]
>
>     so that my interpreted modules don't need to:
>
>        import My.Module
>
>     But i still get:
>
>        Not in scope: data constructor `MyType'
>
>     What am i doing wrong?
>
>     Thanks in advance.
>
>     have fun
>     martin
>
>     _________________________________________________
>     Haskell-Cafe mailing list
>     Haskell-Cafe <at> haskell.org <mailto:Haskell-Cafe <at> haskell.org>
>     http://www.haskell.org/__mailman/listinfo/haskell-cafe
>     <http://www.haskell.org/mailman/listinfo/haskell-cafe>
>
>
Michael Sloan | 21 Dec 01:23 2012
Picon

Re: Hint's setImports usage

Yeah, I've run into that too..

It does seem like there ought to be a better way, but in order to get around that, I just define the imports (or generate) "MyPrelude.hs" in the current directory.  That file can just consist of "import OtherPackage.MyPrelude".

-Michael


On Thu, Dec 20, 2012 at 4:12 PM, Martin Hilbig <lists <at> mhilbig.de> wrote:
oh that's neat!

but what to do if MyPrelude is provided by some package?

i get this error:

  module `MyPrelude' is a package module

and neither

  set [languageExtensions := [PackageImports]]

nor

  {-# LANGUAGE PackageImports #-}

helps.

have fun
martin


On 21.12.2012 00:55, Michael Sloan wrote:
Hello!

Try doing this first:

   loadModules ["My.Module"]

You may also need to set the "searchPath" - it defaults to the current
director.  Another good function to know about is "setTopLevelModules",
which is just like using ":load" in ghci - it imports everything in the
module, including its imports.  So, I often do:

   loadModules ["MyPrelude"]
   setTopLevelModules ["MyPrelude"]

And stick all of the things that I want to be in scope into "MyPrelude.hs".

-Michael


On Thu, Dec 20, 2012 at 3:35 PM, Martin Hilbig <lists <at> mhilbig.de
<mailto:lists <at> mhilbig.de>> wrote:

    hi,

    how to use Language.Haskell.Interpreter.__setImports?


    i use it like:

       setImports ["My.Module"]

    so that my interpreted modules don't need to:

       import My.Module

    But i still get:

       Not in scope: data constructor `MyType'

    What am i doing wrong?

    Thanks in advance.

    have fun
    martin

    _________________________________________________
    Haskell-Cafe mailing list
    Haskell-Cafe <at> haskell.org <mailto:Haskell-Cafe <at> haskell.org>
    http://www.haskell.org/__mailman/listinfo/haskell-cafe
    <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
Martin Hilbig | 21 Dec 02:02 2012
Picon

Re: Hint's setImports usage

On 21.12.2012 01:23, Michael Sloan wrote:
> Yeah, I've run into that too..
>
> It does seem like there ought to be a better way, but in order to get
> around that, I just define the imports (or generate) "MyPrelude.hs" in
> the current directory.

what do you do with the file then? neither loadModules, setImports,
setTopLevelModules helped me :/

have fun
martin

> That file can just consist of "import
> OtherPackage.MyPrelude".
>
> -Michael
>
>
> On Thu, Dec 20, 2012 at 4:12 PM, Martin Hilbig <lists <at> mhilbig.de
> <mailto:lists <at> mhilbig.de>> wrote:
>
>     oh that's neat!
>
>     but what to do if MyPrelude is provided by some package?
>
>     i get this error:
>
>        module `MyPrelude' is a package module
>
>     and neither
>
>        set [languageExtensions := [PackageImports]]
>
>     nor
>
>        {-# LANGUAGE PackageImports #-}
>
>     helps.
>
>     have fun
>     martin
>
>
>     On 21.12.2012 00:55, Michael Sloan wrote:
>
>         Hello!
>
>         Try doing this first:
>
>             loadModules ["My.Module"]
>
>         You may also need to set the "searchPath" - it defaults to the
>         current
>         director.  Another good function to know about is
>         "setTopLevelModules",
>         which is just like using ":load" in ghci - it imports everything
>         in the
>         module, including its imports.  So, I often do:
>
>             loadModules ["MyPrelude"]
>             setTopLevelModules ["MyPrelude"]
>
>         And stick all of the things that I want to be in scope into
>         "MyPrelude.hs".
>
>         -Michael
>
>
>         On Thu, Dec 20, 2012 at 3:35 PM, Martin Hilbig <lists <at> mhilbig.de
>         <mailto:lists <at> mhilbig.de>
>         <mailto:lists <at> mhilbig.de <mailto:lists <at> mhilbig.de>>> wrote:
>
>              hi,
>
>              how to use Language.Haskell.Interpreter.____setImports?
>
>
>              i use it like:
>
>                 setImports ["My.Module"]
>
>              so that my interpreted modules don't need to:
>
>                 import My.Module
>
>              But i still get:
>
>                 Not in scope: data constructor `MyType'
>
>              What am i doing wrong?
>
>              Thanks in advance.
>
>              have fun
>              martin
>
>              ___________________________________________________
>              Haskell-Cafe mailing list
>         Haskell-Cafe <at> haskell.org <mailto:Haskell-Cafe <at> haskell.org>
>         <mailto:Haskell-Cafe <at> haskell.__org
>         <mailto:Haskell-Cafe <at> haskell.org>>
>         http://www.haskell.org/____mailman/listinfo/haskell-cafe
>         <http://www.haskell.org/__mailman/listinfo/haskell-cafe>
>              <http://www.haskell.org/__mailman/listinfo/haskell-cafe
>         <http://www.haskell.org/mailman/listinfo/haskell-cafe>>
>
>
>
Michael Sloan | 21 Dec 02:19 2012
Picon

Re: Hint's setImports usage

Ahh, right!  Now that I think harder about it, as far as I know, there is no way to get Hint to load a module with an extra import.  If it doesn't hide the prelude, then one thing to try would be writing your own "./Prelude.hs" file.  I'd test this, but I'm not currently on a computer with GHC.

If this module is in a package, then there's definitely no way to give it an extra import (it's already compiled).

Hope that helps!

-Michael



On Thu, Dec 20, 2012 at 5:02 PM, Martin Hilbig <lists <at> mhilbig.de> wrote:
On 21.12.2012 01:23, Michael Sloan wrote:
Yeah, I've run into that too..

It does seem like there ought to be a better way, but in order to get
around that, I just define the imports (or generate) "MyPrelude.hs" in
the current directory.

what do you do with the file then? neither loadModules, setImports,
setTopLevelModules helped me :/

have fun
martin

That file can just consist of "import
OtherPackage.MyPrelude".

-Michael


On Thu, Dec 20, 2012 at 4:12 PM, Martin Hilbig <lists <at> mhilbig.de
<mailto:lists <at> mhilbig.de>> wrote:

    oh that's neat!

    but what to do if MyPrelude is provided by some package?

    i get this error:

       module `MyPrelude' is a package module

    and neither

       set [languageExtensions := [PackageImports]]

    nor

       {-# LANGUAGE PackageImports #-}

    helps.

    have fun
    martin


    On 21.12.2012 00:55, Michael Sloan wrote:

        Hello!

        Try doing this first:

            loadModules ["My.Module"]

        You may also need to set the "searchPath" - it defaults to the
        current
        director.  Another good function to know about is
        "setTopLevelModules",
        which is just like using ":load" in ghci - it imports everything
        in the
        module, including its imports.  So, I often do:

            loadModules ["MyPrelude"]
            setTopLevelModules ["MyPrelude"]

        And stick all of the things that I want to be in scope into
        "MyPrelude.hs".

        -Michael


        On Thu, Dec 20, 2012 at 3:35 PM, Martin Hilbig <lists <at> mhilbig.de
        <mailto:lists <at> mhilbig.de>
        <mailto:lists <at> mhilbig.de <mailto:lists <at> mhilbig.de>>> wrote:

             hi,

             how to use Language.Haskell.Interpreter.____setImports?



             i use it like:

                setImports ["My.Module"]

             so that my interpreted modules don't need to:

                import My.Module

             But i still get:

                Not in scope: data constructor `MyType'

             What am i doing wrong?

             Thanks in advance.

             have fun
             martin

             ___________________________________________________

             Haskell-Cafe mailing list
        Haskell-Cafe <at> haskell.org <mailto:Haskell-Cafe <at> haskell.org>
        <mailto:Haskell-Cafe <at> haskell.__org
        <mailto:Haskell-Cafe <at> haskell.org>>
        http://www.haskell.org/____mailman/listinfo/haskell-cafe
        <http://www.haskell.org/__mailman/listinfo/haskell-cafe>
             <http://www.haskell.org/__mailman/listinfo/haskell-cafe
        <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
Michael Sloan | 22 Dec 23:47 2012
Picon

Re: Hint's setImports usage

I've looked into the custom "Prelude.hs" approach, and it's a bit tricky, but does work out:

https://gist.github.com/4361578

The interpreter needs to run in the same directory as your "Prelude.hs".  However, if you try to run "ghci" in that directory, it will fail - because it doesn't know that it needs to load your "Prelude.hs" instead of the ordinary one.  (Seeing ghci fail in the presence of a "Prelude.hs" is the only reason I thought that this might work - and it did!)

Hope that's helpful!

-Michael


On Thu, Dec 20, 2012 at 5:19 PM, Michael Sloan <mgsloan <at> gmail.com> wrote:
Ahh, right!  Now that I think harder about it, as far as I know, there is no way to get Hint to load a module with an extra import.  If it doesn't hide the prelude, then one thing to try would be writing your own "./Prelude.hs" file.  I'd test this, but I'm not currently on a computer with GHC.

If this module is in a package, then there's definitely no way to give it an extra import (it's already compiled).

Hope that helps!

-Michael



On Thu, Dec 20, 2012 at 5:02 PM, Martin Hilbig <lists <at> mhilbig.de> wrote:
On 21.12.2012 01:23, Michael Sloan wrote:
Yeah, I've run into that too..

It does seem like there ought to be a better way, but in order to get
around that, I just define the imports (or generate) "MyPrelude.hs" in
the current directory.

what do you do with the file then? neither loadModules, setImports,
setTopLevelModules helped me :/

have fun
martin

That file can just consist of "import
OtherPackage.MyPrelude".

-Michael


On Thu, Dec 20, 2012 at 4:12 PM, Martin Hilbig <lists <at> mhilbig.de
<mailto:lists <at> mhilbig.de>> wrote:

    oh that's neat!

    but what to do if MyPrelude is provided by some package?

    i get this error:

       module `MyPrelude' is a package module

    and neither

       set [languageExtensions := [PackageImports]]

    nor

       {-# LANGUAGE PackageImports #-}

    helps.

    have fun
    martin


    On 21.12.2012 00:55, Michael Sloan wrote:

        Hello!

        Try doing this first:

            loadModules ["My.Module"]

        You may also need to set the "searchPath" - it defaults to the
        current
        director.  Another good function to know about is
        "setTopLevelModules",
        which is just like using ":load" in ghci - it imports everything
        in the
        module, including its imports.  So, I often do:

            loadModules ["MyPrelude"]
            setTopLevelModules ["MyPrelude"]

        And stick all of the things that I want to be in scope into
        "MyPrelude.hs".

        -Michael


        On Thu, Dec 20, 2012 at 3:35 PM, Martin Hilbig <lists <at> mhilbig.de
        <mailto:lists <at> mhilbig.de>
        <mailto:lists <at> mhilbig.de <mailto:lists <at> mhilbig.de>>> wrote:

             hi,

             how to use Language.Haskell.Interpreter.____setImports?



             i use it like:

                setImports ["My.Module"]

             so that my interpreted modules don't need to:

                import My.Module

             But i still get:

                Not in scope: data constructor `MyType'

             What am i doing wrong?

             Thanks in advance.

             have fun
             martin

             ___________________________________________________

             Haskell-Cafe mailing list
        Haskell-Cafe <at> haskell.org <mailto:Haskell-Cafe <at> haskell.org>
        <mailto:Haskell-Cafe <at> haskell.__org
        <mailto:Haskell-Cafe <at> haskell.org>>
        http://www.haskell.org/____mailman/listinfo/haskell-cafe
        <http://www.haskell.org/__mailman/listinfo/haskell-cafe>
             <http://www.haskell.org/__mailman/listinfo/haskell-cafe
        <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
Martin Hilbig | 21 Dec 00:58 2012
Picon

Re: Hint's setImports usage

ok, i figured it out so far (just after hitting send ;)

'setImports' makes 'My.Modules' stuff available to the interpreted code 
itself (a call to some of my wrapper functions) but not to my "module 
My.Interpreted.Module where" which i use via

   setTopLevelModule ["My.Interpreted.Module"]

So i guess there is no way to add the import to the 
'My.Interpreted.Module' for convenience.

Sorry for the noise.

have fun
martin

On 21.12.2012 00:35, Martin Hilbig wrote:
> hi,
>
> how to use Language.Haskell.Interpreter.setImports?
>
> i use it like:
>
>    setImports ["My.Module"]
>
> so that my interpreted modules don't need to:
>
>    import My.Module
>
> But i still get:
>
>    Not in scope: data constructor `MyType'
>
> What am i doing wrong?
>
> Thanks in advance.
>
> have fun
> martin
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe <at> haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

Gmane