Of Monads and Men

For discussion about, learning of and golfing in Haskell codeg...
Sep 26, 2022 23:53
@DLosc <*> is ap, <$> is map, >>= is bind. I don't know of one for =<< but I tend to think of it as "reverse bind"
Feb 18, 2020 05:30
@flawr yes, A vector of vectors is reasonable.
Feb 17, 2020 19:58
@flawr If you need to index there are data structures better suited for that, such Vectors from the Vector package, or if you also need efficient cons there is Seq from contianers
Feb 10, 2020 07:43
@JonathanFrech I have very little idea, I've never actually written a parser before. Megaparsec apparatnly has some source position stuff: hackage.haskell.org/package/megaparsec-8.0.0/docs/…
Feb 9, 2020 05:50
note: the lexer can also be imlpemented as a monadic parser, that just outputs a stream of tokens
Feb 9, 2020 05:49
@JonathanFrech it is usually better to token with a lexer first, but if what you are doing is very simple, that might be too much hassle.
Jan 6, 2020 09:54
and I just realized some small errors in my first description, both in the omegaPlusOne example and the OmegaTimesTwoPlusOne the last 0 should be a 1
Jan 6, 2020 09:50
@KritixiLithos yes, Homotopy type theory. That last part was mostly me thinking out loud to myself.
Jan 5, 2020 21:05
This just gave me the strange realization that an ordinal in CNF can be represented as a a (finite) multiset of ordinals because of the equivalence between multisets and sorted lists. That probably won't be useful here, but would be interesting to try and prove in HoTT (because I believe the order and the sorting function would have to be defined mutually recursively)
Jan 5, 2020 20:46
I'm not sure which of those two representations is easier to use for this problem.
Jan 5, 2020 20:45
three = O [O [], O [], O[]]
Jan 5, 2020 20:44
In this representation an empty list represents zero, we can represnt an integer by specifying that many times the power 0 in the cantor normal form.
Jan 5, 2020 20:43
There is a more uniform representation that could be used but is slightly different than the one specified in the chellenge that uses the fact that raising something to the power zero is one.

`data Ord = O [Ord]`
Jan 5, 2020 20:40
`data Ordinal = O [Ordinal] Integer`
In other words an ordinal is a list of ordinals along with an integer. The list represents the first n-1 entries from the question and the integer represents the nth entry. So for example we would represent ω as `omega = O [O [] 1] 0` , ω+1 as `omegaPlusOne = O [O [] 1] 0` and ω*2+1 as `OmegaTimesTwoPlusOne = O [O [] 1, O [] 1] 0`
Dec 29, 2019 05:16
@WheatWizard I believe that is the case. I think you need access to some kind of continuation-like behavior to be able to have constructs that would loop in lazy eveluation, but not eager evaluation.
Dec 28, 2019 16:04
Paper I learned this from: pdfs.semanticscholar.org/3a68/…
Dec 28, 2019 16:03
Hm, I thought lazy evaluation always terminates more often than eager evaluation, turn out that is not the case. Consider the expression let _ = raise k in loop for some infinite loop loop. This will loop in a lazy language, but exit non-locally in an eager one.
Dec 26, 2019 14:45
If you have Data.List imported. You can use f l=nub l==l
Dec 2, 2019 10:00
The linearity thing you are probably thinking of is whether folding over a list with (++) as the operation is linear or quadratic. foldr (++) [] xs is linear wheras as foldl (++) [] xs is quadratic because the prefixes keep getting reprocessed in the latter case.
Dec 2, 2019 10:00
@FrownyFrog if has a has length l, b length n, and c length m. a ++ (b ++ c) takes time proportional to l+m whereas the (a ++ b) ++ c takes time proportional to l+(l+m) = 2l+m (assuming everything gets forced). So these are both linear in some sense. The first is more efficient because it doesn't prcess the a twice.
Nov 30, 2019 09:38
@EsolangingFruit no, I actually simplified the code to work out what it was doing: tio.run/##S0oszvj/…
Nov 26, 2019 16:10
@EsolangingFruit I haven't run it to check, but I believe that is an infinite list containing the Fibonacci sequence.
May 14, 2019 04:14
there is a question on stack overflow that is essentially about when that does or doesn't memoize of the exact example you used, I will see if I can find it
May 14, 2019 04:13
@Οurous does eta-reducing n help?
Apr 20, 2019 10:47
@EsolangingFruit does that collect runs of list elements not equal to t?
Mar 23, 2019 15:58
@EsolangingFruit That sounds like a question you should ask at computer science stack exchange. Actually that is something that I would be interested in an answer to as well.
 

  Logic

This room is meant for discussion about logic, including found...
May 13, 2020 05:32
@user21820 thanks for the link to the zoo of ordinals. There are many ordinals between the first recursively Mahlo and the first ordinal such that L_alpha models ZFC that I was not aware of.
May 13, 2020 03:06
Found it. It was actually in Simply Beautifal Art's chatroom: chat.stackexchange.com/transcript/message/44141809#44141809
May 13, 2020 02:35
It was posted here as either an image or a link to a short PDF.
May 13, 2020 02:33
@MaliceVidrine The table I'm thinking of was laid out like the one on the nLab, but much larger.
May 12, 2020 13:28
I remember a huge table that that was posted here a long time ago. It compared the strength of various logical systems (type theories, set theories, theories of inductive definitions, etc.). I have been unable to find it by using the chat search. Does anyone remember it and possibly have a link?
 

 The Nineteenth Byte

The Nineteenth Byte: General discussion for codegolf.stackexc...
Dec 26, 2019 16:00
@KritixiLithos no, ⍵×⍵ + ⍵×⍵ is the same as ⍵×⍵×2 which is different from ⍵×⍵ = 2×⍵×⍵
Nov 26, 2019 16:41
The naive way of just picking positions for each each card randomly and trying again if it overlaps can fail in some situations. Example: the large rectangle is 4 cards wide and 1 card tall, we want to place 3 cards. The first card(s top-left corner) gets placed at (2/3,0) the second card at (7/3,0). but now we don;t have a large enough space to place the 3rd card.
Nov 26, 2019 16:34
Are all small rectangles the same size?
 

 talk.tryitonline.net

For general discussion and feature requests regarding tryitonl...
Oct 5, 2019 20:50
oops, my fault, I had an empty string as a compiler argument
Oct 5, 2019 20:48
@Dennis Not sure if it is a bug in TIO or ghc but this program is not linking correctly: https://tio.run/##y0gszk7Nyfn/XyE3MTNPwcpKwdNfwTOvhAvCt1UoSi0pLcpTMPj//19yWk5ievF/AA

The program works when I run it locally, but that is with a newer version of GHC (8.6.3) and I believe using `ld` rather than `gold`
Oct 3, 2019 19:04
@Dennis yes, the error code 1 is a bug, as of a few hours ago there is a patch from upstream located here: bugzilla.redhat.com/show_bug.cgi?id=1729682#add_comment
Oct 3, 2019 14:07
That also makes more sense, because you were using Fedora 27 then, which actually had bc 1.07
Oct 3, 2019 14:05
ooh, dc version 1.4 from bc 1.07 has an exit code of 0, so this has changed between 1.07 and 1.07.1
Oct 3, 2019 13:58
@Dennis yes, current version of GNU dc and the fedora dc are 1.4.1 from bc 1.07.1. Both have an exit code of 1 on the q command. I just downloaded bc 1.06 from source which has dc 1.3. That has an exit code of 0 on the q command.
Oct 3, 2019 13:48
looking at bc versions in fedora, you might have had version 1.06.95 installed at that time
Oct 3, 2019 13:45
@Dennis I just downloaded version 1.06 of GNU dc, that has an exit code of 0
Oct 3, 2019 13:21
I have found the source code for a non-gnu dc lying around on my computer, that dc has an exit code of 0 when I use the quit commend.
Oct 3, 2019 13:19
@Dennis You made this comment a few days before stasoid commented out dc in the polyglot driver, probably related.
Oct 3, 2019 13:01
@Dennis yes same (exit code 1) behavior on my machine (Fedora 29), but it worked (exit code 0) a bit over a year ago on TIO.
Oct 3, 2019 09:07
more specifically the exit code
Oct 3, 2019 09:07
@Dennis Something is going wrong with dc. codegolf.stackexchange.com/questions/102370/…
Mar 17, 2019 15:16
@Dennis do you prefer to link to the home page of the language like you do for GCC or the code repository like you do for a lot of esolangs? If the first, the ATS website is ats-lang.org/Home.html
Mar 17, 2019 13:56
@Dennis maybe that should be a bug report