- Join over
**1.5M+ people** - Join over
**100K+ communities** - Free
**without limits** - Create
**your own community**

The online hangout for Göteborg Functional Programming Group and everybody interested.

overloading is less constraining

How does resolution work though? Could you show an example?

No, not using newtypes.

In PureScript type class instances are global, but I think this is not necessarily the case in Haskell, no?

```
newtype Sum n = Sum n
instance Num n => Semigroup (Sum n) where
Sum x <> Sum y = Sum (x + y)
instance Num n => Monoid (Sum n) where
mempty = Sum 0
newtype Product n = Product n
instance Num n => Semigroup (Product n) where
Product x <> Product y = Product (x * y)
instance Num n => Monoid (Product n) where
mempty = Product 1
```

that's what I meant with Sum & Product

"However, it is relatively simple to construct example programs which violate global uniqueness of instances in an observable way"

"Locally, all type class resolution was coherent: in the subset of instances each module had visible, type class resolution could be done unambiguously."

if two different modules provide two different type class implementation for the same type but are imported separately

ok got it

Or

`Ord`

method rather.
I don't really understand how this works; I just remembered Marco showing me this a couple of years ago and I just found this article by googling. :-)

I found this with the overloading: https://deque.blog/2017/06/14/10-things-idris-improved-over-haskell/

The real problem of why Set is not a monad in Haskell is that it requires Ord. Mathematically there's no issue.

last time I wrote idris a bit "seriously" was like 2 years go, I'm starting to forget some stuff :p I should get back to it maybe this year :D

so the Set

`do`

would kind of behave like a List monad @jolod ?
I can try to do that later today

(So

`x <- Array.fromFoldable xs`

.)
there you go @jolod :

```
module SetMonad
import Data.SortedSet
(>>=) : (Ord a, Ord b) => SortedSet a -> (a -> SortedSet b) -> SortedSet b
(>>=) xs fn = foldr (\elem, accu => union (fn elem) accu) empty xs
pure : Ord a => a -> SortedSet a
pure a = fromList [a]
shenaningans : SortedSet Int
shenaningans = do
a <- fromList [1,2,3]
b <- fromList [1,2,3]
pure (a * b)
result : List Int
result = Data.SortedSet.toList shenaningans
```

(kind of need to force evaluation on the result with :x at the repl though, my understanding is that

`do`

has lazy semantics)
Random question, but does anyone know where the style of very abbreviated function/variable names come from? It seems to be very common in C. I think maybe some old language had a restriction on having one-letter names for things like loop variables or something like that, but C does not have such restriction.

Unique in first 8 characters is a rather strict requirement on length.

That explains so much!