Skip to content

Major restructure of the module: - #101

Merged
idontgetoutmuch merged 2 commits into
interface-to-performancefrom
restructure
Apr 21, 2020
Merged

idontgetoutmuch merged 2 commits into
interface-to-performancefrom
restructure

Conversation

@lehins

@lehins lehins commented Apr 17, 2020

Copy link
Copy Markdown
Collaborator

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
Comment thread System/Random.hs
, uniformR
, genByteString
, Random(..)
, Uniform

@curiousleo curiousleo Apr 20, 2020 •

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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 done
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