Hi!
I'm really excited to announce a new collection of libraries that we've developed at Co–Star for working with free monads.
We love working with the freer-simple
package and are so excited to help grow the ecosystem surrounding free monads. As part of the initial release, we have published 5 small libraries for working with time, random numbers, http requests, catching IO exceptions, and automatically profiling code that uses `Eff`.
More info at https://gitlab.com/costar-astrology/freer-simple-contrib (including links to Hackage)
I'd imagine it would. Whenever I've used freer, every meaningful interaction I have with the outside world (SQL query, Redis query, API request) is captured by a single constructor for a single effect. I end up emitting statsd metrics for these by hand by wrapping my calls to them. freer-simple-profiling
would help automate that, giving me automated timers + counters. Seems nice and useful!
This is a great example use case. You could even group related effects together (i.e. a few known queries under one `Query` effect) while aggregating at the constructor and effect level simultaneously.
I think that it would be a step in the right direction to address it differently... I can't quite explain it perfectly, but I'll try.
So leading with "I'm a vegan" makes it sound like a boast, or a point that speaks for itself like I should just respect that point because. And while that may be the case, especially in this discussion, it doesn't open the doors to acceptance. It's kinda like having a body builder come up to you and say "I'm a body builder, you could be too" and flexing a bunch. He might be right, but it doesn't motivate me to emulate him.
Instead, maybe try to beat around the bush with it. "I remember how hard it was when I converted to veganism," or "Yeah back when I decided to try vegan..."
This makes it seem more like a choice that a normal person (like me) made, instead of the "I am vegan, vegan is better" stigma that people hear. And to revisit the (maybe bad, but bear with me) bodybuilder analogy, it sounds more achievable when someone talks about their gym routine than when you're just looking at the results.
I'm literally making this up on the spot with no forethought, but as a meat-eater who is 100% receptive to reducing my consumption, I think that would make it easier for me to hear it from a /gasp vegan without grinding my teeth.
What is stopping you from reducing your meat consumption? Check out /r/veganrecipes it you want some inspiration on what to cook.
In practice you don’t even have to cook anything that’s radically different than your usual recipes, just choose a meat substitute at the grocery store. You also don’t have to worry about nutritional changes until you are cutting out animal products entirely.
newtype Foo m a = Foo (m a)
instance MonadIO m => MonadIO (Foo m) where
liftIO io = Foo $ do
liftIO $ print "before"
res <- liftIO io
liftIO $ print "after"
return res
then
runFoo (liftIO (print "hi") >> liftIO (print "bye"))
(Though this is questionable as Foo's MonadIO isn't a monad homomorphism now.
Makes sense. With the freer approach, we can actually make the function I wrote above polymorphic over an arbitrary effect parameter by replacing the @IO
type application.
You can make a newtype
for every monad in your mtl
stack, but is there anyway to do it generically?
You can work in Free f
, and then have the interpose action fire between each interpreted layer of f
if you really feel the need to do this.
Something like:
foldFree (\io -> liftF $ print "before" *> io <* print "after") $ do
liftF $ print "hi"
liftF $ print "bye"
(I don't have a compiler handy at this exact moment to test.)
You can choose different effects to call out as f
in FreeT f m
if you have one particular f
that matters to you. Here you don't have to lie about liftIO
being a monad homomorphism, either.
Does using FreeT
within mtl
not have the same performance overhead that something like freer-simple
would have?
Load more comments
This is so cool! Would love to see it adapted for mandolin
Hi, Indian medical student here. I’m guessing from your username you’re Indian as well.
Firstly: Is your mother vegan? Does she believe in this lifestyle? Is she wanting to avoid dairy, or are you trying to make her avoid dairy? If your mother is not vegan, I think this question is pretty pointless. She can just follow the advice of her doctors.
Secondly: doctors are far from idiots. Please don’t make assumptions. I agree that veganism is a very rare lifestyle in India, and not many people (including doctors) are aware of it. So it follows that they will continue to recommend only what they know to be healthy, without considering whether or not it’s vegan. It’s not your doctor’s job to recommend diets to you according to your personal beliefs; obviously, doing so is very admirable, but doctors who don’t do this aren’t idiots.
Thirdly: veganism is the elimination of unnecessary animal exploitation to an extend that is possible and practicable. That’s what this subreddit says on the home page. This automatically means that medical issues are an exception: harming animals in self-defence is just the law of nature.
Finally: As for your mother’s condition, milk (cow/buffalo) milk is one of the best things for improving her bone strength and density. Also look into calcium supplements; some plant based milks (soy milk, for example) are also fortified and do contain decent amounts of calcium. If your mother is really determined to follow a vegan diet in spite of her health, she can try these alternatives. They may not be as effective, but obviously it’s for her to decide whether her beliefs or her health is more important to her at this point. For example, I have a cut-off point for all health indicators, and if my levels fall below this point (where it’s likely that this will cause significant health issues), I will consume animal based products. Many drugs that people take routinely are not vegan. There’s a high chance even you consume several non-vegan medications.
Bottom line is that this is entirely your mother’s decision, not yours. It’s great that you want to help her out, but I think you need to accept that the decision is hers in the end, and be supportive if it’s going to help improve her health.
As for the medical aspect: osteoporosis might not have much to do with dairy consumption (it does have a significant effect) , but fractures of the vertebrae suggest pretty advanced disease. At this point, even if dairy only contributes 1% towards bone health, it’s something your mother should be considering.
There are so many vegan options that have more calcium than dairy milk.
I don't know anything about PSI but perhaps the free pump is mainly used by delivery drivers riding scooters etc that have higher pressure?
I'm pretty sure the likelihood of it being a scam is about zero.
Larger tires have lower PSI usually
One can have compassion and still enjoy tasty animals.
No, if you eat animals you can’t really say that you have compassion for them
You might just be better off making two separate types for Y
and Z
but if you really want them to be one type, you could do this with GADTs:
data X (a :: Bool) where
Y :: X 'True
Z :: X 'True -> X 'False
How did you take a picture of this
Co-Star is a mobile application combining traditional methods of astrology with NASA data and modern technology to create a branded, hyper-personalized and social astrology experience. Since our launch in October 2017, Co-Star has grown incredibly quickly and was ranked in Apple's top 100 entertainment app weeks after launch. We are an early stage startup (we just raised a seed round of funding) looking to expand the team as we continue to gain traction and develop the app!
Our backend is written in Haskell, and we want you to help us work on it! We love types at Co-Star, and we try to use them as much as possible to catch bugs and make sure our code is correct. We are using a combination of Servant and free monads which makes mocking and testing a total breeze. We're working on open sourcing some of our free monad effects libraries at the moment.
If you know some Swift or have worked with AWS before, that's a huge plus.
If this sounds interesting to you, send us an email jobs(∀)costarastrology.com
Check out our website at https://www.costarastrology.com
(Since this is the first role we're hiring for, we're looking for someone local to NYC. Future positions will likely be remote OK, so keep an eye out for more postings if you're not from NYC)
Why not freer-simple? :)
It didn't exist when we started working on this! Can I ask though, why did you chose to fork instead of make a PR?
That’s a good reason! I’m mostly just teasing. To answer your question, though, two reasons:
I did make a PR, but it was never merged, and indeed, freer-effects seems unmaintained.
My API is not backwards-compatible with freer-effects’s because it intentionally removes and renames some exports to make the API easier to understand.
Cool, good to know. We're definitely excited to see the free monad ecosystem develop, so making sure that we're using the most up to date and widely supported/used library is important to us!
I just started working on getting a small library we're using ready to open source, here's a preview of it (it uses freer-effects though 😁) freer-catching. And many more to follow!
Load more comments
Can you make it generate code that compiles next?
Me too thanks
Doesn’t say that in the article, does it?
20 cops paid a visit to his apartment.
Sounds like harassment to me.
The super
lens should lead to an equivalent prism when all disjunctive clauses of one ADT appear in another.
I started working on a constructor prism: https://github.com/benweitzman/generic-lens/blob/master/src/Data/Generics/Sum/HasConstructor.hs
How sad of a human being do you have to be to preach this non sense.
I think part of the problem is that the person who wrote this comment is probably using the word "racism" to refer to what most people would call "institutionalized racism".
When someone calls you a bigot, that's a deep personal attack and it's hard not to take it personally. But for the most part, people who are "racist by default" are not bigots, or even bad people most of the time. You don't have to hate or think you are better than people from other races to participate in institutionalized racism. There are certain prejudices that have been ingrained in all of us that may be totally unconscious in the individual but collectively show up as big issue when predominantly white people are the ones with power in our society.
Neat! Was this inspired by my recent monad-persist package (which is basically the same thing but for mtl style), or is the timing just coincidental?
Totally coincidental! I'm pretty amazed at how close in time these are popping up.