I'm no expert on algebras, but I think the way to work on this is not to think "what Racket constructs are close that I might coopt to express what I want?" but instead to think "what do I want my programs to look like" and then design the language from there, reusing libraries as they seem helpful or designing new ones that do what you want. Racket's language-implementation facilities are pretty powerful (of course, if there is nothing like what you end up needing, there will still be actual programming to do ;).
Robby On Tue, Jan 19, 2021 at 4:58 PM Stuart Hungerford < [email protected]> wrote: > Hi Racketeers, > > I'd like to try re-implementing a library for experimenting with abstract > algebraic structures in Racket (that is groups, fields, rings etc, not > algebraic data types like sum or product types). With Racket's strong > numeric hierarchy and programmable programming language philosophy it seems > like a good environment for experimenting with mathematical structures. > > This library was originally developed in Rust and more recently Haskell > and made heavy use of Rust traits and Haskell typeclasses to implement > these structures for the builtin numeric types as a well as my own derived > numeric types (e.g. finite fields). I understand Racket is not Haskell (or > Rust) and naively trying to emulate typeclasses or traits in Racket will > likely lead to un-idiomatic code. Having said that, what Racket idioms > would be most useful for this kind of project? > > A typical typeclass (from the Haskell version) would be: > > ``` > class Monoid a => Group a where > > inverse :: a -> a > > power :: Int -> a -> a > ``` > > Thanks, > > Stu > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/racket-users/a1ce47b2-9dab-4b33-b50b-557bfef7e331n%40googlegroups.com > <https://groups.google.com/d/msgid/racket-users/a1ce47b2-9dab-4b33-b50b-557bfef7e331n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CAL3TdOM_pt6EfuXvov8jWb_%3D9u%2BqaKh2UN7bhaaYFYruaQmfJg%40mail.gmail.com.

