Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major restructure of the module: #101

Merged
merged 2 commits into from
Apr 21, 2020

Conversation

lehins
Copy link
Collaborator

@lehins lehins commented Apr 17, 2020

This is more of what I had in mind when I suggested the restructure.

  • Separate System.Random into:
    • System.Random.Internal that hold most of the classes,
      internal functions and some of the instances
    • Sytstem.Random that export the pure interface only. That means
      RandomGen, Random, Uniform and UniformRange classes
    • System.Random.Monad all of the monadic functionality plus the
      re-export of the full System.Random module.
  • Split the relevant parts of documentation into Pure and Monadic and
    place them into their corresponding modules

lehins added 2 commits April 17, 2020 22:36
* Separate `System.Random` into:
  * `System.Random.Internal` that hold most of the classes,
    internal functions and some of the instances
  * `Sytstem.Random` that export the pure interface only. That means
    `RandomGen`, `Random`, `Uniform` and `UniformRange` classes
  * `System.Random.Monad` all of the monadic functionality plus the
    re-export of the full `System.Random` module.
* Split the relevant parts of documentation into Pure and Monadic and
  place them into their corresponding modules
, uniformR
, genByteString
, Random(..)
, Uniform
Copy link
Collaborator

@curiousleo curiousleo Apr 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #96, I decided not to export Uniform and UniformRange from System.Random because their definitions use MonadRandom:

class Uniform a where
  uniformM :: MonadRandom g s m => g s -> m a

In other words, in my understanding, Uniform and UniformRange as they are currently defined are part of the monadic interface, not part of the pure interface.

If a user only imports System.Random, it is not clear to me how they could use uniformM / uniformRM given that MonadRandom will not be in scope. Am I missing something here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two functions exported couple lines above uniform and uniformR. They allow usage of instances of Uniform and UniformRange type classes with pure RandomGen while hiding the fact that it is done through the MonadRandom. Which is pretty neat I think ;)

But because definitions uniformM and uniformRangeM use MonadRandom for implementation, they are not exported from System.Random, so you are partially right.

@idontgetoutmuch idontgetoutmuch self-requested a review April 20, 2020 17:21
@idontgetoutmuch idontgetoutmuch merged commit 0d4c8cd into interface-to-performance Apr 21, 2020
@idontgetoutmuch idontgetoutmuch deleted the restructure branch April 21, 2020 07:30
@curiousleo curiousleo mentioned this pull request Apr 21, 2020
3 tasks
curiousleo pushed a commit that referenced this pull request May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants