modules as implicit data structures

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

modules as implicit data structures

Petr Pudlák
Hi Cafe,

Let's say we have a module like

module Foo where

foo, bar :: String -> Something
...

and use it elsewhere as

import qualified Foo as F
...
F.foo ...

This is almost just if we had a data type defined as

data FooModule = FooModule { foo :: String -> Something, bar :: String -> Something }

together with a singleton `f : :FooModule` and referenced it as f.foo, f.bar etc.

Has some language explored this idea of making modules explicit as language-level objects? It seems that there could be some interesting possibilities, such as:

- Abstract modules (just a definition of the data type). Then
- Being able to replace a module with a different one (like a fake one for testing).
- Polymorphic modules that could be instantiated for specific types.

Thanks,
Petr

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: modules as implicit data structures

Tom Ellis-5
On Thu, Sep 06, 2018 at 11:42:49AM +0200, Petr Pudlák wrote:

> Let's say we have a module like
>
> module Foo where
>
> foo, bar :: String -> Something
> ...
>
> and use it elsewhere as
>
> import qualified Foo as F
> ...
> F.foo ...
>
> This is almost just if we had a data type defined as
>
> data FooModule = FooModule { foo :: String -> Something, bar :: String ->
> Something }

Related reading

    http://www.haskellforall.com/2012/07/first-class-modules-without-defaults.html
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: modules as implicit data structures

Steven Leiva
In Elixir/Erlang, module references are just atoms. (https://elixir-lang.org/getting-started/basic-types.html#atoms)

You could bind a name to one module and then rebind it to another module. 

On Thu, Sep 6, 2018 at 5:24 AM Tom Ellis <[hidden email]> wrote:
On Thu, Sep 06, 2018 at 11:42:49AM +0200, Petr Pudlák wrote:
> Let's say we have a module like
>
> module Foo where
>
> foo, bar :: String -> Something
> ...
>
> and use it elsewhere as
>
> import qualified Foo as F
> ...
> F.foo ...
>
> This is almost just if we had a data type defined as
>
> data FooModule = FooModule { foo :: String -> Something, bar :: String ->
> Something }

Related reading

    http://www.haskellforall.com/2012/07/first-class-modules-without-defaults.html
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.


--

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: modules as implicit data structures

Sven Panne-2
In reply to this post by Petr Pudlák
Am Do., 6. Sep. 2018 um 11:43 Uhr schrieb Petr Pudlák <[hidden email]>:
[...] Has some language explored this idea of making modules explicit as language-level objects? It seems that there could be some interesting possibilities, such as: [...]

You might want to have a look at Standard ML's signatures, structures and functors, they are probably what you're thinking about.

Cheers,
   S.

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: modules as implicit data structures

Petr Pudlák
Thank you everyone, these are some very interesting pointers to explore!

Petr

čt 6. 9. 2018 v 15:01 odesílatel Sven Panne <[hidden email]> napsal:
Am Do., 6. Sep. 2018 um 11:43 Uhr schrieb Petr Pudlák <[hidden email]>:
[...] Has some language explored this idea of making modules explicit as language-level objects? It seems that there could be some interesting possibilities, such as: [...]

You might want to have a look at Standard ML's signatures, structures and functors, they are probably what you're thinking about.

Cheers,
   S.

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: modules as implicit data structures

Hiromi ISHII
Hi Petr,

I think Agda's module system is something similar to your conception.
In Agda, you can treat modules and records interchangably.

> 2018/09/11 1:16、Petr Pudlák <[hidden email]>のメール:
>
> Thank you everyone, these are some very interesting pointers to explore!
>
> Petr
>
> čt 6. 9. 2018 v 15:01 odesílatel Sven Panne <[hidden email]> napsal:
> Am Do., 6. Sep. 2018 um 11:43 Uhr schrieb Petr Pudlák <[hidden email]>:
> [...] Has some language explored this idea of making modules explicit as language-level objects? It seems that there could be some interesting possibilities, such as: [...]
>
> You might want to have a look at Standard ML's signatures, structures and functors, they are probably what you're thinking about.
>
> Cheers,
>    S.
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
----- 石井 大海 ---------------------------
[hidden email]
筑波大学数理物質科学研究科
数学専攻 博士後期課程三年
----------------------------------------------


_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

signature.asc (499 bytes) Download Attachment