Haskell modules: Morton's fork?

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

Haskell modules: Morton's fork?

Nikita Churaev
Option 1:

    module App.Component (Foo, Bar, Qux) -- re-exports
    module App.Component.Foo (Foo, make, func1, func2)
    module App.Component.Bar (Bar, make, func1, func2)
    module App.Component.Qux (Qux, make, func1, func2)

API clients will have to write long import lists:

    import App.Component
    import qualified App.Component.Foo as Foo
    import qualified App.Component.Bar as Bar
    import qualified App.Component.Qux as Qux


Option 2:

    module App.Component (module Foo, module Bar) -- re-exports
    module App.Component.Foo (Foo, makeFoo, fooFunc1, fooFunc2)
    module App.Component.Bar (Bar, makeBar, barFunc1, barFunc2)
    module App.Component.Qux (Qux, makeQux, quxFunc1, quxFunc2)

Now you can import easily:

    import App.Component

But now you have to prefix your functions, just like in C...

Is there another, cleaner option?
_______________________________________________
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: Haskell modules: Morton's fork?

Rein Henrichs
A typeclass with the shared functions as members is an option. YMMV on whether it is cleaner.

On Fri, Jul 21, 2017 at 1:56 PM Nikita Churaev <[hidden email]> wrote:
Option 1:

    module App.Component (Foo, Bar, Qux) -- re-exports
    module App.Component.Foo (Foo, make, func1, func2)
    module App.Component.Bar (Bar, make, func1, func2)
    module App.Component.Qux (Qux, make, func1, func2)

API clients will have to write long import lists:

    import App.Component
    import qualified App.Component.Foo as Foo
    import qualified App.Component.Bar as Bar
    import qualified App.Component.Qux as Qux


Option 2:

    module App.Component (module Foo, module Bar) -- re-exports
    module App.Component.Foo (Foo, makeFoo, fooFunc1, fooFunc2)
    module App.Component.Bar (Bar, makeBar, barFunc1, barFunc2)
    module App.Component.Qux (Qux, makeQux, quxFunc1, quxFunc2)

Now you can import easily:

    import App.Component

But now you have to prefix your functions, just like in C...

Is there another, cleaner option?
_______________________________________________
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.