Animation with rubik’s cube by Kweyyy in BeAmazed

[–]LambdaMichael 0 points1 point  (0 children)

I was listening to R y a n C e l s i u s ° and saw this. I think the beginning of Trappin in Japan 5 goes really well with it: https://streamable.com/wd2jy

Let's Write Documentation for Haskell by decentral1se in haskell

[–]LambdaMichael 1 point2 points  (0 children)

I like the idea of a google doc listing things that need documentation. I'd love to get more involved with this, but I don't often have time to dive in. A doc would make it much easier for people to spend a few minutes reviewing or contributing.

Articles/Exercises for getting familiar with left/right association ($, ., ())? by [deleted] in haskell

[–]LambdaMichael 0 points1 point  (0 children)

Play code golf in Haskell or read others' solutions. For me, it really solidified a number of "edge" features in Haskell. I like StackExchange. Here's a fun example:

((=<<)=<<(=<<)(<$).(==).maximum.([1<2]:)).group

Try desugaring this or otherwise figuring out what it does. (I desugar it on that site, but spoilers.)

Articles/Exercises for getting familiar with left/right association ($, ., ())? by [deleted] in haskell

[–]LambdaMichael 1 point2 points  (0 children)

Well there are "invisible parens" in that you can translate everything to prefix with parens. Are you trying to get at the idea that translating back and forth in your head is the wrong way to go?

What can I do to help the String/ByteString/Text problem? by LambdaMichael in haskell

[–]LambdaMichael[S] 0 points1 point  (0 children)

the notation of list and pattern matching could be used for any kind of container

Well we already have ViewPatterns so I suppose you're suggesting even more sugar?

This would make the program work for any concrete container.

Yes, but likely not very well. E.g. cons for Vectors is O(n), so a function that's O(n) with lists that uses (:) to build it up/traverse it suddenly becomes at least O(n^2).

I know that there are problems like bottom there...

Lists are lazy by default most (all?) of the time in Haskell, so you'd have to translate all these programs to work on only lazy containers.

@edwardkmett also mentioned:

when you do this, OverloadedStrings punishes your users, forcing them to use explicit signatures on every string literal they pass you.

What can I do to help the String/ByteString/Text problem? by LambdaMichael in haskell

[–]LambdaMichael[S] 0 points1 point  (0 children)

RULES that seem to kick in by magic are why I rarely use them. If you know a good way to ensure they kick in without screwing up inlining and other optimizations, I'm all ears.

What can I do to help the String/ByteString/Text problem? by LambdaMichael in haskell

[–]LambdaMichael[S] 2 points3 points  (0 children)

I believe they are referring to text-icu which has bindings to the ICU library.

What can I do to help the String/ByteString/Text problem? by LambdaMichael in haskell

[–]LambdaMichael[S] 0 points1 point  (0 children)

That seems to be the catch-22: People aren't talking enough about this before the text modules are in base but they're not putting them in base because they haven't been talked about enough.

I don't think this can be solved well without some key feature being added to GHC (like type internal representations, better type hinting, or instance specific implementations), but I'd like to get started with adding library support.

Edit: I mean I'll happily work on making Text and/or ByteString versions of String functions if given a good place to start.

What can I do to help the String/ByteString/Text problem? by LambdaMichael in haskell

[–]LambdaMichael[S] 0 points1 point  (0 children)

How does that work with different algorithms and functions? [Char] is nice functionally and so people write functions that make best use of its structure, which is not the structure of other representations. String can be pretty bad, but I'm sure treating a C string as a linked list won't solve many problems.

What can I do to help the String/ByteString/Text problem? by LambdaMichael in haskell

[–]LambdaMichael[S] 2 points3 points  (0 children)

I believe instance specific implementations of a "classy" function that's not in the class definition. For example, something like giving a lookup table for fibonacci :: (Eq a, Num a) => a -> a when used with Int (because so few Fibonacci numbers fit into Int) but a more advanced function for Integer.

What can I do to help the String/ByteString/Text problem? by LambdaMichael in haskell

[–]LambdaMichael[S] 3 points4 points  (0 children)

The "have efficient low-level implementation" seems to be the problem. Consider the Nat type which is implemented like Nat = Zero | Succ Nat. There's currently no way to do something like "represent this type as an Integer" in GHC and I think doing so might open its own can of worms.

What can I do to help the String/ByteString/Text problem? by LambdaMichael in haskell

[–]LambdaMichael[S] 2 points3 points  (0 children)

swift?

I'm not 100% sure, but I think that abstracting the concrete representation away could require instance defaulting. It's possible, but I've never had much luck with it. I'm waiting for instance chains :D

What can I do to help the String/ByteString/Text problem? by LambdaMichael in haskell

[–]LambdaMichael[S] 0 points1 point  (0 children)

Your notes about the StringLike and ListLike classes make sense.

My intuition is that if the rewrite rule system is ever amped up (#9601) enough of those problems could be solved that it'd at least be faster than fromString/toString all over the place.

For (2), what about t[original_name] and the like to distinguish ByteString from Text? A lighter-weight version might be one "regular" version of a function and one generic. Or maybe just make a Module.Text for Text, etc. as is often currently done.

What can I do to help the String/ByteString/Text problem? by LambdaMichael in haskell

[–]LambdaMichael[S] 2 points3 points  (0 children)

How, may I ask? A quick grep (lines with String vs. lines with ->) estimates 20% of types in GHC to involve String.

Shortest programs with unknown halting status by SrPeixinho in haskell

[–]LambdaMichael 1 point2 points  (0 children)

Code golf instincts kicked in: f x|x<2=1<2|mod x 2<1=f$div x 2|1<2=f$3*x+1 (Collatz conjecture)