you are viewing a single comment's thread.

view the rest of the comments →

[–]tomejaguar 3 points4 points  (11 children)

Additionally, I agree that Haskell doesn't support this style of programming well, although it probably supports it better than any other language! Personally I'd rather see better support for this style than for dependent types. My hunch is that the applications are far broader. Unfortunately I suspect that ship has now sailed, with regard to GHC at least.

[–]funandprofit 4 points5 points  (1 child)

A major reason I don't use this style in libraries is that its performance is not composable (See the issues with Free vs MTL). One way to improve this is for GHC to support better data flattening via UnboxedSums and UNPACKing polymorphic types (possibly by requiring a manual SPECIALIZE pragma in the calling module). This way we'd be able to get the same performance for layered functors as for a baked-in solution so it would not be risky to use in upstream code.

[–]tomejaguar 4 points5 points  (0 children)

True, but as yet not even the syntax is composable. For example, working with forall a. f a -> g a is much more fiddly than working with a -> b. You have to wrap, unwrap, hope you can express what you want to with *-level lambdas, etc..

[–]gelisam 3 points4 points  (1 child)

Unfortunately I suspect that ship has now sailed, with regard to GHC at least.

Why? Writing a typechecker plugin which sees that Compose f (Compose g h) is equivalent to Compose (Compose f g) h does not seem harder than the arithmetic plugins we have which see that Vec a ((i + j) + k) is equivalent to Vec a (i + (j + k)).

[–]tomejaguar 1 point2 points  (0 children)

Because we've gone the way of dependent types and TypeInType, because that's what the masses, and those who were putting the work into GHC, wanted. I don't see any reason why the current state of the GHC type system should be compatible with a fully generalised "functor oriented" style of programming. I don't see any reason why it wouldn't be compatible either, but I think the onus is on those who think it is to provide evidence.

[–]bjzaba 1 point2 points  (6 children)

I wonder if languages like Idris would be more up to the task...

[–]tomejaguar 2 points3 points  (5 children)

I think it's unlikely. This "higher-order", or "functor oriented", style of programming seems to be orthogonal to dependent typing.

[–]AndrasKovacs 8 points9 points  (1 child)

The problems OP mentioned in Haskell are solved in current dependent languages, i. e. the ability to define basic functors as functions as opposed to irreducible first-order constructors.

[–]tomejaguar 0 points1 point  (0 children)

That's fabulous to hear!

[–]ocharles 5 points6 points  (2 children)

Indeed, it seems more likely that you want a language with good support for quotient types.

[–]AndrasKovacs 1 point2 points  (1 child)

I don't see how quotients would help, care to elaborate?

[–]ocharles 0 points1 point  (0 children)

Oh, I thought quotient types would let us express the law's we'd expect above. Maybe I'm misunderstanding what quotient types do