I’m a computer janitor that sometimes streams trying to learn dev https://www.twitch.tv/destide

  • 9 Posts
  • 125 Comments
Joined 2 years ago
cake
Cake day: July 4th, 2023

help-circle






  • Destide@feddit.uktoProgrammer Humor@programming.devMonads
    link
    fedilink
    English
    arrow-up
    34
    arrow-down
    1
    ·
    edit-2
    29 days ago

    God, you guys are idiots, it’s so simple

    • You take a Function
    • ???
    • Result It can’t be simpler /s

    No joke that’s pretty much every example I came across trying to get my head around it :D.

    Not sure if using analogies is helpful or just going to be more confusing but, the way I think of a monad is similar to how I used to cook back when I worked in restaurants. I’d prep all my ingredients in small containers so I wouldn’t forget anything, and they’d be ready to go when needed. Then I’d start adding them to the main mixing bowl, one step at a time. If I forgot an ingredient or accidentally flipped the bowl, the recipe would fail — you can’t keep baking after that.

    So a monad is like that bowl: if you mess up, it just dumps everything out and resets your little prep bowls, instead of letting you keep going and make a batch of shitty cookies

    The “main-bowl” is the monad (the context that holds your values).

    The “prep bowls” are the individual values or functions ready to be chained.

    The “dump/reset” is the idea that once something goes wrong, the chain stops safely.

    And “shitty cookies” are the result of not putting a monad in place and just sending it.

    Maybe someone with a more diverse programming background can explain it better. But it’s basically a function checker usually wraped in IF ELSE and RETURN.

    Some pseudo code in case my analogy doesn’t make sense.

    def main():
        bowl = get_flour()
        bowl = add_butter(bowl)
        
        if bowl is None:
            return "Recipe failed — restart!"
    
        bowl = add_sugar(bowl)
        
        if bowl is None:
            return "Recipe failed — restart!"
    
        return bake(bowl)
    



  • To use tailscale you’d need to add every device you want to use to your tailscale machines list. It’s not an anywhere any machine solution without that.

    If you want something more like a proper web service that’s available without Tailscale, you’d need to spin up a reverse proxy or use Tailscale Funnel to expose Jellyfin to the public internet in a controlled way.

    Tailscale won’t affect local as you can access it via browser and phone, the service is running fine locally. Just check in jellyfin it’s bound to the same IP subnet go to Dashboard → Networking and check that it’s set to 0.0.0.0 or your LAN IP (e.g., 192.168.0.xx).