2025/12/12

Newest at the top

2025-12-12 12:26:11 +0100 <Enrico63> No?
2025-12-12 12:26:10 +0100 <Enrico63> which means that the implementation of foo is choosing a=Int, which could not be the case if foo was rank 1, because the caller would choose a.
2025-12-12 12:25:32 +0100 <Enrico63> foo x = x + 1
2025-12-12 12:25:31 +0100 <Enrico63> foo :: (forall a. a) -> Int
2025-12-12 12:25:31 +0100 <Enrico63> For instance, this compiles
2025-12-12 12:24:48 +0100trickard_trickard
2025-12-12 12:23:47 +0100 <Enrico63> It should be rank 2, I understand
2025-12-12 12:23:33 +0100 <mauke> that still leaves (forall a. a) -> Int at rank 1
2025-12-12 12:23:18 +0100merijn(~merijn@host-vr.cgnat-g.v4.dfn.nl) merijn
2025-12-12 12:23:08 +0100 <lucabtz> yeah you were missing what Enrico63 added :P
2025-12-12 12:22:53 +0100 <mauke> lucabtz: that one is mergeable
2025-12-12 12:22:31 +0100 <Enrico63> *which are nested and cannot be merged with a previous one*
2025-12-12 12:22:31 +0100 <lucabtz> mauke: it doesnt though, it says forall a. a -> (forall b. b -> a) is rank 1
2025-12-12 12:21:21 +0100 <mauke> the wiki page defines "rank" as the number of foralls in the type
2025-12-12 12:20:59 +0100 <Enrico63> so that means `(forall a. a -> a) -> b` is rank 2, to my understanding. How is `(forall a. a) -> Int` any different in this respect?
2025-12-12 12:20:26 +0100 <Enrico63> then in `(forall a. a -> a) -> b`, where there's an implicit `forall b.` in front of everyting, b is chosen by the caller, but a is chosen by the implementation
2025-12-12 12:19:41 +0100 <Enrico63> and the caller "chooses" the `a`
2025-12-12 12:19:13 +0100pabs3(~pabs3@user/pabs3) (Ping timeout: 246 seconds)
2025-12-12 12:19:07 +0100 <Enrico63> `forall a. a -> a` (e.g. the type of id) is rank 1
2025-12-12 12:18:53 +0100 <Enrico63> Yeah, how's that? `Int -> Int` is rank 0, right?
2025-12-12 12:18:40 +0100 <mauke> this doesn't feel right
2025-12-12 12:18:26 +0100humasect(~humasect@dyn-192-249-132-90.nexicom.net) (Remote host closed the connection)
2025-12-12 12:18:21 +0100 <mauke> but then, according to that page (forall a. a) -> Int is rank 1
2025-12-12 12:18:04 +0100 <Enrico63> Umpf
2025-12-12 12:17:20 +0100 <mauke> according to the wiki page, it's rank 2
2025-12-12 12:17:12 +0100 <Enrico63> mauke, that is rank 3?
2025-12-12 12:16:59 +0100 <mauke> is that rank-2?
2025-12-12 12:16:30 +0100 <mauke> forall b. ((forall a. a -> b) -> b) -> b
2025-12-12 12:16:06 +0100 <lucabtz> i think rank N means it has rank N-1 as its arguments, the base case rank 0 being a monomorphic value/function
2025-12-12 12:15:15 +0100trickard_(~trickard@cpe-83-98-47-163.wireline.com.au)
2025-12-12 12:15:05 +0100 <Enrico63> I kind of get that. I suppose I want to do a quiz to make sure I have truly understood, rather than memoized some patterns
2025-12-12 12:13:44 +0100 <Enrico63> Whereas rank 2 means that the implementation (i.e. the inner scope) chooses the type variable of the inner forall
2025-12-12 12:12:39 +0100 <haskellbridge> <loonycyborg> With rank 1 all variables are set at outer scope and you won't be passing any polymorphic functions.
2025-12-12 12:12:37 +0100 <Enrico63> loonycyborg, yeah, I'm also (halfway) there
2025-12-12 12:12:31 +0100trickard(~trickard@cpe-83-98-47-163.wireline.com.au) (Read error: Connection reset by peer)
2025-12-12 12:12:08 +0100 <haskellbridge> <loonycyborg> I personally found the trick to understanding rank-n is that they're about polymorphic functions that can take other polymorphic functions.
2025-12-12 12:12:00 +0100merijn(~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 245 seconds)
2025-12-12 12:10:10 +0100 <mauke> (the answer is yes)
2025-12-12 12:09:41 +0100 <Enrico63> Yeah, I don't quite get what's unclear to me, so I asked those previous questions to have something to hinge on
2025-12-12 12:08:52 +0100 <mauke> well, it's what I would've used to answer your question :-)
2025-12-12 12:07:52 +0100 <Enrico63> I come _from_ that page
2025-12-12 12:07:01 +0100 <mauke> https://wiki.haskell.org/Rank-N_types
2025-12-12 12:06:09 +0100 <Enrico63> It is rank 2, correct?
2025-12-12 12:06:02 +0100 <Enrico63> Well, that's the same as `forall b. (forall a. a -> a) -> b`
2025-12-12 12:05:37 +0100 <Enrico63> (Be damned the formatting, ahhah)
2025-12-12 12:05:25 +0100 <Enrico63> Instead, if I have `(forall a. a -> a) -> b`, that's rank 2, right?
2025-12-12 12:03:53 +0100 <lucabtz> yes rank 1
2025-12-12 12:02:08 +0100 <Enrico63> The id function has type `forall a. a -> a` which is rank 1, right?
2025-12-12 12:02:07 +0100 <Enrico63> Hi, there. I'd like some clarification on rank-n types.
2025-12-12 12:00:40 +0100Enrico63(~Enrico63@host-95-251-99-143.retail.telecomitalia.it) Enrico63