Skip to content

Update Modules and Functors Tutorials #1778

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

Merged
merged 53 commits into from
Jan 30, 2024
Merged

Update Modules and Functors Tutorials #1778

merged 53 commits into from
Jan 30, 2024

Conversation

cuihtlauac
Copy link
Collaborator

@cuihtlauac cuihtlauac commented Nov 20, 2023

Reorganise, update and complete tutorials on Modules and Functors. The draft outline follows. Top-level items are stand-alone tutorials.

  • Introduction to the Module System
    • In “Get Started” or “Module System” (TBD)
    • Story on names & clashes
    • Separate Compilation
    • Separation of Concerns
    • Information Hidding / Encapsulation
    • Each item has min two links
      • Wikipedia or ext. ref
      • Relevant OCaml tutorial or ref. man
  • Using Modules
    • Using Standard Library & Opam modules (content from 1st program)
  • Writing Modules
    • Reference to “1st” program + Additional Material
  • Module Includes and Hierarchy
    • Submodules (extracted from existing “Modules” doc)
    • Module Inclusion (extracted from existing “Modules” doc)
    • Dune include_subdirs qualified/unqualified
  • Encapsulation
    • Module Signatures
    • Private definitions
    • Abstract Types (extracted from existing “Modules” doc)
    • Keyword private (Ref man chap 12)
  • Using Functors
    • Signatures
    • Instantiating Functors
  • Writing Functors
    • Defining a Functor

Open questions:

P.S. As of creating this PR, it doesn't patch anything. Only discussion


A functor is a module that is parametrised by another module, just like a
function is a value which is parametrised by other values, the arguments.
A functor is just a parametrized module.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the older description was better here since it describes a functor by analogy with something else that people may be familiar with.

I'd take it a little further and say that functors are functions but that instead of regular values they take modules as inputs and create modules as outputs.

This intuition I think can help with other things, like the "transitive closures leading to modules" prerequisite.

Copy link
Collaborator Author

@cuihtlauac cuihtlauac Dec 11, 2023

Choose a reason for hiding this comment

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

Sorry, I should have said that what I've written here is interim text. The original intro had some good ideas but it needs to be rewritten. This also applies to the transitive closure thing, of course we're not going to publish this as is.

Copy link
Contributor

Choose a reason for hiding this comment

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

No worries, and nothing to be sorry for! 🙏🏼

Copy link
Collaborator Author

@cuihtlauac cuihtlauac Dec 19, 2023

Choose a reason for hiding this comment

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

Should we also say something like this?

The term functor comes from a branch of mathematics called category theory. Although OCaml functors are loosely inspired by them, no knowledge of that math is required to understand and work with OCaml functors. Functors in Haskell more closely represent the Category Theory concept and are, have nothing in common with OCaml functors.

cuihtlauac pushed a commit that referenced this pull request Dec 14, 2023
Copy link
Contributor

@christinerose christinerose left a comment

Choose a reason for hiding this comment

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

Some initial comments/suggestions/questions
Haven't double checked the code yet.

Copy link
Contributor

@christinerose christinerose left a comment

Choose a reason for hiding this comment

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

Initial comments/suggestions/questions for functors.md

sabine pushed a commit that referenced this pull request Dec 20, 2023
cuihtlauac pushed a commit that referenced this pull request Dec 20, 2023
sabine pushed a commit that referenced this pull request Dec 21, 2023
sabine pushed a commit that referenced this pull request Dec 22, 2023
sabine pushed a commit that referenced this pull request Dec 27, 2023
sabine pushed a commit that referenced this pull request Jan 3, 2024
sabine pushed a commit that referenced this pull request Jan 10, 2024
sabine pushed a commit that referenced this pull request Jan 11, 2024
sabine pushed a commit that referenced this pull request Jan 11, 2024
sabine pushed a commit that referenced this pull request Jan 12, 2024
sabine pushed a commit that referenced this pull request Jan 12, 2024
sabine pushed a commit that referenced this pull request Jan 30, 2024
@cuihtlauac cuihtlauac merged commit 3b89a8b into main Jan 30, 2024
@cuihtlauac cuihtlauac deleted the doc-modules branch January 30, 2024 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants