guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Idiomatic Guile for semigroup/monoid/group?


From: Stuart Hungerford
Subject: Re: Idiomatic Guile for semigroup/monoid/group?
Date: Mon, 3 Jan 2022 10:46:22 +1100

On Sun, Jan 2, 2022 at 9:46 PM Maxime Devos <maximedevos@telenet.be> wrote:

> > In Haskell/Idris/Purescript/Swift/Rust I'd be looking to
> > typeclasses/protocols or traits to model a semigroup, monoid or group.
> > In OOP languages I'd be looking to some kind of abstract base class to
> > model each structure.
> >
> > What would the idiomatic Guile forms be to work with these structures?
> > Would it involve GOOPS or records?
>
> I wouldn't recommend using GOOPS methods, because a carrier set can
> have many groups.
>
> E.g., on the rational numbers (<rational> in GOOPS), both the
> multiplication group and the addition group can be defined, but they
> aren't isomorphic. (I'm ignoring 0 here)
>
> My suggestion is to do as Haskell does, but make type class instances
> explicit.

Thanks for that advice -- much appreciated.

> Anyway, possibly things like this are already implemented in Theme-D
> (not sure though): looking at the properties of Theme-D listed at
> <https://www.tohoyn.fi/theme-d/>:

That's very interesting. I'd been wondering if there was an extension
for Guile that did what Typed Racket does for Racket or what Coalton
does for Common Lisp.

Just out of interest, are there other multimethod/ad-hoc polymorphism
approaches for Guile?

Thanks,

Stu



reply via email to

[Prev in Thread] Current Thread [Next in Thread]