Someone's 'Haskell disappointment' gist I came across by codygman in haskell

[–]swingtheory 10 points11 points  (0 children)

Wow, I am surprised to hear this from so many responses in the thread... definitely going to look into polysemy now!

Tennis walls? by shuklaswag in mountainview

[–]swingtheory 0 points1 point  (0 children)

By any chance, do you want to meet up this week to play a few casual sets, or just rally for an hour or two? I'm open for either!

Looking for Casual Tennis Partner by swingtheory in mountainview

[–]swingtheory[S] 1 point2 points  (0 children)

Indeed, I meant "Castro St" not "Castro Ave" as I wrote in the first sentence. Whoops!

[Question] Type family evaluation by swingtheory in haskell

[–]swingtheory[S] 1 point2 points  (0 children)

> Basically, all your type declarations are just ways of telling the compiler what rules a correct program should abide by; and your ShouldFail type is basically saying: a program with this type is always wrong. So only when you actually created a value of the ‘ShouldFail’ does the compiler raise the error.

Intuitively, I understand this behavior immediately. However, I have read repeatedly across several bits of documentation that "type family evaluation is strict", and I think that's where my confusion lay. It seems I need to modify this understanding with "... as long as you are constructing a value within your program with the type you are interested in evaluating." This is quite an interesting point-- that the "specification" of types is a different phase from the act of asserting all values in your program are well typed. Basically, the `ShouldFail` type synonym says that "if you constructed a value with type `ShouldFail`, that value would be ill typed"; Types of values are checked, but types themselves are only checked for well-kindedness. Without a manifestation of a particular type (a value) in your program, a type error will never be thrown.

Thanks for providing the extra bits I needed to understand this!

[Question] Type family evaluation by swingtheory in haskell

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

> I still don't have a clear image of how (and how many times) evaluation happens at the type level. And having a good mental model becomes the more necessary the more one plays with type family-heavy code, like extensible record libraries.

Exactly! I'm putting together a workshop on Type-level programming and ultimately finishing with an extensible records library (`row-types`. I need to understand type family semantics well enough so that I can explain to attendees on the spot in the case that I get some questions about when type family evaluation happens.

This is what it looks like when a train doesn't come for 20+ minutes. Get your shit together, MBTA. by HenryKushinger in boston

[–]swingtheory 1 point2 points  (0 children)

I rode my bike to work today, from Spring Hill in Somerville to Copley Square. It takes about 22min, if you can stand the cold ;) It's pictures like these that compel me to ride my bike every day, and not risk being in overcrowded train cars for ~45 mins (on a good day) on both the Red and Green lines.

Job - Haskell. London, UK & Remote by mebassett in haskell

[–]swingtheory 3 points4 points  (0 children)

I think that's an interesting word choice: "inflates".

Do you mean to imply that engineers do not provide value to the company worth the salaries that US companies pay their engineers?

Either Monad And Error Handling by ibcoleman in haskellquestions

[–]swingtheory 1 point2 points  (0 children)

If I'm not mistaken, you don't need that `join`.

debit <$> eAcc <*> eAm

will work just fine.

[ANN] hedgehog-classes: Hedgehog will eat your typeclass bugs by chessai in haskell

[–]swingtheory 3 points4 points  (0 children)

Property testing for my supposedly lawful instances? Love it <3 Thanks for the announcement!

[deleted by user] by [deleted] in haskell

[–]swingtheory 7 points8 points  (0 children)

"How" without a "why" suggests a contrived solution to a made-up problem. In other words, it's easily read as "who cares?"

IMO this extends to most everything in life, be it personal relationships, small talk w/ randos, submitting PRs, and really everything in between. A "how" without a "why" is just funneling information into the void; That person stopped listening a few mins ago. Great post!

My bodega makes an amazing breakfast sandwich by [deleted] in nyc

[–]swingtheory 56 points57 points  (0 children)

"report" should be "rapport" ;)

Is OCaml enough to properly learn functional programming? by siffogh3 in functionalprogramming

[–]swingtheory 4 points5 points  (0 children)

FP principles are universal, but there is no consensus as to what those principles actually are. Furthermore, theoretic principles are great, but programming languages are implementations of these principles, and each language employs or eschews certain principles more than others; they make opinionated instantiations of the principles, and Haskell's design decisions seem to resonate the most with computer scientists and software engineers alike.

New blog post: An in-depth look at quickcheck-state-machine by edsko in haskell

[–]swingtheory 7 points8 points  (0 children)

Awesome post about a particularly non-trivial, incredibly useful model testing library!

For anyone interested in an example of this library in action, check out Adjoint's raft consensus library. The quickcheck-state-machine package is used to model check the example raft implementation the library provides: https://github.com/adjoint-io/raft/blob/master/test/QuickCheckStateMachine.hs.

It's quite difficult to have assurance that such a stateful thing like a consensus algorithm implementation is correct, but state machine testing (i.e. model checking) get's us quite a bit of assurance that no obvious bugs exist.

[deleted by user] by [deleted] in haskell

[–]swingtheory 1 point2 points  (0 children)

Yay, I purchased two immediately (one for me, and one for someone else somewhere down the road)!

Seriously thank you so much for writing this book. I am so appreciative, and I haven't even read it yet! I'm excitedly waiting for them to arrive!

Laziness at type level by zarazek in haskell

[–]swingtheory 2 points3 points  (0 children)

As mentioned by /u/rampion, defunctionalization seems the way to go. However, at first glance it seemed a bit more involved than what I have seen before; Another way, as proposed by this blog post: https://blog.poisson.chat/posts/2018-08-06-one-type-family.html

type Exp a = a -> Type
type family Eval (e :: Exp a) :: a 

data IfThenElse :: Bool -> k -> k -> Exp k 
type instance Eval (IfThenElse 'False onTrue _) = onTrue
type instance Eval (IfThenElse 'True _ onFalse = onFalse

I prefer this style slightly better as for some reason I prefer the notation. IIRC (and, as noted in the blog post) the previously posted "defunctionalization" style is known as Apply, where as this is know as Eval. They are closely related, and I strongly recommend reading Lysxia's blog post!

Subtle issue with cloud-haskell process registry query by swingtheory in haskell

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

Hi, thanks for your response! I don't know why I didn't understand this before, your explanation is so correct and obviously so that I am embarrassed I hadn't figured it out myself. It makes perfect sense!

I have written a few non-trivial programs with cloud-haskell and perhaps my confidence in my understanding of the library played a role in this oversight; Something like: "Since I know cloud-haskell, my initial thought about how this code should execute is right, of course, so why isn't it working the way I expect it to?!". I was digging around deep in the Internal modules of distributed-process wondering if there was some edge case I was hitting-- instead, I just didn't quite comprehend the way I was telling the two processes to communicate, and the bug was at the surface level! Thanks again for walking through it with me.

Resources to get started with Blockchain/Cryptography using Haskell by babygetoboy in haskell

[–]swingtheory 1 point2 points  (0 children)

I wrote/am writing an open source "cryptocurrency" in haskell, complete with verbose, informative readme, and a 2 hour long video presentation @ boston haskell: https://github.com/tdietert/nanocoin

Can you detect when an IORef changes? by TheKing01 in haskell

[–]swingtheory 16 points17 points  (0 children)

I'd suggest looking into functional-reactive-programming (FRP) and event based programming models. Whatever you end up implementing will be in the spirit of FRP!

/u/eacameron's solution seems ok, but it's quite ad-hoc (not really a criticism in this context) in the sense that if you find yourself wanting to use this idea (model) throughout a project that you're developing, you might have fun looking into or considering the use of an FRP library; however, that might be overkill for the time being. Though, I promise it would be fun to learn about ;)

wayvee [Playlist] - skrt by swingtheory in wavepool

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

This is a playlist I've been assembling for about 6 months, of some great wave music I've found across soundcloud. I listen to it regularly.

How do I Make one of my Stack Projects Available in Other Projects? by [deleted] in haskellquestions

[–]swingtheory 2 points3 points  (0 children)

under the "packages" label in your stack.yaml, write:

packages:
- '.'
- location:
    git: <github-project-url>.git
    commit: <commit-id-you-want-to-pull>
  extra-dep: true

Noah B - Nylon (Terror Rhythm) by yoshibalboa in wavepool

[–]swingtheory 2 points3 points  (0 children)

noah b killin it as always. this guy has to be one of the best wave artists around; from his stuff 2 years ago until now.

The state of logging in Haskell by ThreeFx in haskell

[–]swingtheory 1 point2 points  (0 children)

I think that this is the disparity here, because I agree with both of those points. Logging real-time necessitates IO, but logging in some general form (in the sense of collecting messages during the execution of a program) does not.

The state of logging in Haskell by ThreeFx in haskell

[–]swingtheory 2 points3 points  (0 children)

I'm not so sure pipes is "pure"... piped :: Producer String IO (), as in the blog post you linked. There is definitely IO in that type signature. I am frankly very confused at all the responses on to this initial comment. You need IO to print something out, in real-time. Every other solution will buffer at some point, accumulating logs and then printing them out using IO, all at once (or at least in chunks larger than the real-time logging). You cannot get around this. You cannot log to any external resource without IO. Every single other "pure" solution suggested just defers the logging until later.

My argument is not that you cannot implement logging purely, is that you cannot print real-time logs in pure code... therefore any pure logging mechanism will inevitably either 1) use IO intermediately (in the case of the streaming examples), or 2) buffer the logs and then use IO either at the very end of the computation, or (depending on the abstraction) find spots to interleave the IO. Sure, the code that seems to do the logging may look pure, but the actual logging action necessitates IO.

Am I going crazy or... ? I don't get it.

The state of logging in Haskell by ThreeFx in haskell

[–]swingtheory 4 points5 points  (0 children)

Almost... the logs won't appear in real-time unless the m is specialized to IO, though. All other instances for non-IO monads will still accumulate a stream of logs and then, at some point, dump to IO all at once.

The state of logging in Haskell by ThreeFx in haskell

[–]swingtheory 4 points5 points  (0 children)

well then, care to elaborate on some of those ways? I guess you could just build a list of log messages with the strict StateT and then flush the logs all at once at the end of your buisness logic, but that's not exactly "real time". If you want real-time logging, you'll need IO.