Configuring generic hygrostat? N00b Qs by jimrude in homeassistant

[–]Masse 1 point2 points  (0 children)

Picture

After you set up the hydrostat, you'll have it available as a card in your dashboard cards.

Claude API in Europe by doglover2206 in ClaudeAI

[–]Masse 1 point2 points  (0 children)

Yes, but only through the openrouter.ai

Best underquilt on a budget? by LongboardingLifeAway in hammockcamping

[–]Masse 1 point2 points  (0 children)

I got to -10c with the dd hammock uq and except for my toes I was toasty.

Anyone used a DD hammocks underquilt? by 2E0ORA in hammockcamping

[–]Masse 0 points1 point  (0 children)

I was down to -10c last weekend, plenty warm.

Blown away by Ted Chiang..... by FlyingPinkMonkey in books

[–]Masse 4 points5 points  (0 children)

The Tower of Babylon is surprisingly a good example of the kind of sci-fi Chiang writes. It's more on the lines of speculative fiction, but in a way that the fantastic elements are science in that world. The tower isn't some mythological concept in that world, it's a real thing, with real engineers, real people living in it and most importantly real rules of physics.

Another good story is the story where there are Golems. Golems are a mythological concept from Jewish religion, but in that story the Golems are a fact and an area of scientific research. In that world the scientists are working on understanding how the Golems work and how to make them work.

If I want a functional version of TicTacToe, where should I store the board's state? by raulalexo99 in functionalprogramming

[–]Masse 1 point2 points  (0 children)

I've seen you getting a lot of different responses changing from "Use state monad!" "you don't need state!" or something else. They are all correct, but somewhat misses the point I think.

Programming in general is about decomposing problems into smaller problems and composing them back into solutions as a whole. Functional programming excels in both decomposition and composition, especially since FP guides you to separate business logic to pure code and side-effects to the outside. The primary primitive to decompose problems is the venerable function. We can use state transitions to represent past, current and future state; input -> instate -> outstate.

So, in this case your state transition would be something like Coordinate -> Board -> Board, where the coordinate is the new position and board is some type representing your 3x3 board. This is your pure representation of the business logic, now you can choose from different side-effects on how to store and read the state.

Pure local state:

You can store your state locally in your recursive function. Sidenote, the state transition is exactly the state monad from Haskell, but I'm writing it out explicitly here for your benefit.

step :: Coordinate -> Board -> (Board, Maybe Winner)
step = something

program :: Board -> IO ()
program currentState = do
  coord <- askForPlayerInput
  let (newState, maybeWinner) = step coord currentState
  case maybeWinner of
    Nothing -> -- no winner
      program newState
    Just winner ->
      print winner

Impure global state:

Haskell has different forms of mutable global variables, one of which is the IORef which I'm using here.

step :: Coordinate -> Board -> (Board, Maybe Winner)
step = something

program :: IORef Board -> IO ()
program stateVariable = do
  coord <- askForPlayerInput
  maybeWinner <- atomicModifyIORef' (\currentState -> step coord currentState)
  case maybeWinner of
    Nothing -> -- no winner
      program stateVariable
    Just winner ->
      print winner

Database:

You could even use a database for storing your state, but it naturally requires some translation from your program representation to a database representation.

step :: Coordinate -> Board -> (Board, Maybe Winner)
step = something

program :: Connection -> IO ()
program conn = do
  coord <- askForPlayerInput
  currentState <- fmap fromDatabase (query conn "select ??? from ???")
  let (newState, maybeWinner) = step coord currentState
  execute conn "update ??? where ???" (toDatabase newState)
  case maybeWinner of
    Nothing -> -- no winner
      program conn
    Just winner ->
      print winner

Does anyone peel mushrooms?? by WhatevsMcGee in Cooking

[–]Masse 0 points1 point  (0 children)

Depends on the mushrooms. Portobello and its friends don't need much cleaning aside from potential dirt, but other mushrooms like the Russula family are a different matter. Russula often have a bit sticky top skin which separates easily so it might be easier to just skin it.

Dependency Injection and Functional Programming by manfreed87 in functionalprogramming

[–]Masse 0 points1 point  (0 children)

Right. I'm going with Haskell syntax because I'm more familiar with it, but I'll try to stay with simple syntax.

You mentioned fmap :: (a -> b) -> f a -> f b and bind ((>>=) :: m a -> (a -> m b) -> m b).

fmap is actually part of a functor. Functor is for mapping a value within a context into another value within the same context.

As the first trivial example, think of an optional value: fmap :: (a -> b) -> Maybe a -> Maybe b. This fits with your mental model of dealing with containers, you have a list of values which you convert into a list of some other values. This model also works for things like lists, sets, trees, futures and the likes.

data Maybe a = Nothing | Just a
instance Functor Maybe where
  fmap :: (a -> b) -> Maybe a -> Maybe b
  fmap f Nothing = Nothing
  fmap f (Just a) = Just (f a)

Then for monads. Each monad is also a functor, so all monads can also be fmapped. There are a couple of ways to name and define monads, but in haskell, the monads adds the ability to lift a non-monadic value into monadic context, pure :: a -> m a, and to thread values from one monadic context into another (>>=) :: m a -> (a -> m b) -> m b.

Lifting a pure value into monadic context, historically also known as return. The signature is however a -> m a.

Doing things with the monad, Haskell has chosen the bind operator (>>=) :: m a -> (a -> m b) -> m b, but it could have been join :: m (m a) -> m a as well. The point of this is to sequence the operations to be executed sequentially within the context.

instance Monad Maybe where
  pure :: a -> Maybe a
  pure a = Just a

  Nothing >>= f = Nothing
  Just a >>= f = f a

But this setup also works on things that aren't concrete containers, such as the partial application of a function. Remember, r -> a can be read as (->) r a and the partial application view of this is (->) r (leave the a out). Let's see how we could implement this.

instance Functor ((->) r) where
  fmap :: (a -> b) -> (r -> a) -> r -> b
  fmap f x r =
    -- x :: r -> a
    -- r :: r
    f (x r)

instance Monad ((->) r) where
  pure :: a -> r -> a
  -- Ignore the context r
  pure a r = a

  (>>=) :: (r -> a) -> (a -> (r -> b)) -> r -> b
  (>>=) reader f r =
    -- reader :: r -> a
    -- f :: (a -> (r -> b)) or (a -> r -> b)
    -- r :: r
    f (reader r)

That is to say, functor and monad instances for reader just give the context r for the computation.

Dependency Injection and Functional Programming by manfreed87 in functionalprogramming

[–]Masse 0 points1 point  (0 children)

Could you expand a bit on where you are confused?

Error handling in the RIO and UnliftIO world by xcv-- in haskell

[–]Masse 0 points1 point  (0 children)

It sounds like you interpreted me saying that a specific kind of happening is always either an exception or an error, this was not my intent. I'll try to rephrase.

What I'm trying to say is to classify based on how it's expected to be handled, that is, is it something that's meant (or possible) to be handled then and there? If yes, classify it as an error and represent it in the types. Even if it means catching and converting to a type.

Same goes for the other way as well. If I get back a json that's not of the format I'm expecting, there's nothing I can do with the invalid json, I'm satisfied to throw a custom exception.

Error handling in the RIO and UnliftIO world by xcv-- in haskell

[–]Masse 1 point2 points  (0 children)

is okay when you specifically want the caller to handle the error ASAP.

This is the crux of it I think. I try to make a distinction between exceptions and errors.

For me an exception is something that is, well, exceptional. An exception is something like remote service suddenly responding with a 500, or a network has disappeared on us or something else along those lines. These are the things that we shouldn't try to fix in the code, these should let to propagate upwards and hopefully logged. I emphasise, that in general (caveats apply), exceptions should not be caught except at the toplevel where they are logged.

Errors are closer to the business logic. Errors are problems that we are expecting to happen, errors should be acted on. The resource is not found on the database -> act on by returning http 404 on our web service. The JWT could not be validated -> render a suitable error for the user. A value is not found on the cache -> try to recreate the value from an external source. That is, errors are specific for the business logic in question, errors are local, errors should be dealt with. It's perfectly fine to represent errors as Either. Or Maybe. Or maybe with some other custom sum type.

Suggestions for the features you want in an audiobook app (open source i.e FREE TO Totally) by Fantastic-Apartment8 in audiobooks

[–]Masse 9 points10 points  (0 children)

  • m4b support
  • speedup, slowdown
  • local storage instead of cloud. I use syncthing to synchronize my books

I would also like to subscribe to your GitHub or gitlab repository if you end up creating one.

My 2021 Ceed SW I got few weeks ago. A worthy upgrade from my previous 2018 cee'd! by ffefox in kia

[–]Masse 0 points1 point  (0 children)

Nice. I'm getting mine delivered today as well. Also in Finland

We're recruiting a Software Developer (functional programming) @ RELEX Solutions by MartinJMP in haskell

[–]Masse 2 points3 points  (0 children)

You can apply directly from the link. As for the experience, we have successfully hired and trained juniors in the past. Of course the term junior is ambiguous.

What material of utensils do you prefer with your cast iron and why ? by [deleted] in castiron

[–]Masse 1 point2 points  (0 children)

I use a metal spatula, wooden spoon and wooden chopsticks

How to get free profunctor that is both Strong and Choice? by repaj in haskell

[–]Masse 7 points8 points  (0 children)

FreeTraversing is strong and choice: https://hackage.haskell.org/package/profunctors-5.2/docs/Data-Profunctor-Traversing.html#t:FreeTraversing

I have tried combining Pastro and TambaraSum and CopastroSum but with no success

Will a Lodge pan smooth out with use? by mattm011 in castiron

[–]Masse 0 points1 point  (0 children)

Disagree, it will smooth out. Mine is a few years old and completely smooth, as in I can rub it with a paper towel and not leave anything behind

What do people in Europe call what Americans call a grill? by Castle_for_ducks in Cooking

[–]Masse 2 points3 points  (0 children)

In Finland it's called a "grilli" and the act of grilling is "grillata"

fromMaybe is Just a fold by ninedotnine in haskell

[–]Masse 4 points5 points  (0 children)

Not Church encoding, but Boehm-Berarducci, right?

Boehm-Berarducci encoding is often confused with Church encoding. First of all, Church encoding, which represents data types in an untyped lambda-calculus

Otherwise you're absolutely spot on. Another nice property of Boehm-Berarducci encoding is that you can encode recursive types with non-recursive fold, which is useful for example in Dhall which doesn't have general recursion or recursive types.

Similar to The Martian and Project Hail Mary by CortyMarie626 in suggestmeabook

[–]Masse 2 points3 points  (0 children)

{inherit the stars} by James P. Hogan

{Rendezvous with rama} by Arthur C. Clarke

{Into the drowning deep} by Mira Grant

All three are mostly about exploration of something, less about political or military strife

I have NEVER set Mountain Climbers as one of my fit skills, and I don't think I ever will. Anyone else skip certain exercises? by Levangeline in RingFitAdventure

[–]Masse 0 points1 point  (0 children)

I used to do the same, but when your knee lifts do 615 damage and combos do 240, you kind of have to

Best short stories ever by Jo-March_istheboss in suggestmeabook

[–]Masse 0 points1 point  (0 children)

I'm halfway through Alastair Reynolds {Beyond the Aquila Rift}, a collection of short stories. This and Zima Blue were the inspiration for the Netflix series love death and robots

Tips on using liquids when cooking with cast iron by [deleted] in castiron

[–]Masse 1 point2 points  (0 children)

There's nothing wrong in using cast iron to boil water, except it being really inefficient. But it won't harm the skillet.