wfdctrl

u/wfdctrl


r/NixOS•

Is there a declarative way to manage NixOS virtual machines? What I have in mind: A configuration DSL where you can specify what virtual machines you want and the resources needed for each virtual machine and a process that creates the virtual machines from this specification. So, something like NixOps except that it doesn't try to sync the configuration with some external hypervisor, but is the hypervisor itself (on bare metal). That way you could have a git repository with the current configuration and a CD pipeline that creates the machines (and the entire thing would just work without constant babysitting).

I expect the answer is no, because I couldn't find anything, but you never know

77

r/ocaml•

I'm using phantom types to track whether the elements of a sorted list are unique. The signature of the module is as follows:

type nonuniq
type uniq

type elt
type _ t = private elt list

val of_list: elt list -> nonuniq t
val inter: ? t -> ? t -> ? t
val uniq: _ t -> uniq t
...

The problem is how to specify the signature of the intersection. val inter: 'state t -> 'state t -> 'state t is not good enough because an intersection between a list with unique and a list with non-unique elements makes sense and results in a list with unique elements. Basically the return type would need to be a result of a boolean OR function:

uniq -> uni
134

r/NixOS•

When I reboot the frequency of the CPU is around 1.2GHz (according to cpupower frequency-info). However when I wake it up from suspend the frequency is around 2.0GHz and I stays like that indefinitely. The CPU is in "powersave" mode in both cases.

NixOS version 21.05

analyzing CPU 0:
  driver: intel_cpufreq
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 20.0 us
  hardware limits: 1.20 GHz - 3.30 GHz
  available cpufreq governors: powersave performance schedutil
  current policy: frequency should be within 1.20 GHz and 3.30 GHz.
                  The gov
104

r/ocaml•

I have a bunch of functions of the form: state -> params -> state, where state is a record. After profiling I realized that 50% of cycles in that region are spent in GC. I guess Ocaml can't tell it is safe to reuse the record and keeps allocating new ones. One option would be to make the record fields mutable, however I would prefer to keep the code pure.

Is there any other way to restructure the code to avoid the allocations?

1714

r/haskellquestions•

Are there common names for these three types of trees:

a) data Tree1 a = Node1 a [Tree1 a]
b) data Tree2 a = Leaf2 a | Node2 [Tree2 a]
c) data Tree3 a b = Leaf3 a | Node3 b [Tree3 a b]

I know b) is usually called a leafy tree. What about a) and c)?

29

r/learnmath•

I saw this is in a paper and I can't wrap my head around how it works.

Basically you have a nested sum:

[;\sum_{m_1 = n}^0 \sum_{m_1 = m_2}^0 ... \sum_{m_{k - 1} = m_{k - 2}}^0 1;]

And that somehow calculates the number of k-compositions for n.

Wolfram alpha example for n = 5 and k = 3:

https://www.wolframalpha.com/input/?i=%28sum+%28sum+1%2C+m2+%3D+m1+to+0%29%2C+m1+%3D+n+to+0%29%2C+n+%3D+5

My interpretation is m_1 = 5, then m_2 = m_1, so m_2 = 5 and all of these numbers are larger than 0. WTF?

25

r/compsci•

The non-deterministic machine splits the computation into many branches whenever it encounters a choice. However sometimes you have a problem where the computation first diverges and then some of the branches end up in the same state and continue down the same path. If the branches join, the worst-case complexity of the algorithm is polynomial and not exponential and the computation traces a graph and not a tree. Does such a machine (class of algorithms) have a special name? The CFG parsing algorithms work like this.

6114

r/ocaml•

I have a few functions that I would like to have available everywhere. If I use "open PervasivesExt" in every file I get an error if I don't use any of them. I suppose there doesn't exist a compiler flag to open a module globally. What would be the best approximation?

24

r/buildapc•

Hi,

I will mainly use this computer for programming, editing photographs, long term data storage and a bit of gaming.

Is 1650S good enough for some light 2k gaming?

For the monitors I plan to go with two AOC Q3279VWFD8, any better options? (only one will be used for gaming).

I picked the motherboard because of the 6 SATA connectors. A Wi-Fi chip would also be welcome, however this one is super cheap for some reason, so paying 60 eur more for example MSI MORTAR doesn't make sense.

The parts I intend to buy are here:

PCPartPicker Part List

TypeItemPrice
CPU[AMD Ryzen 5 3600 3.6 GHz 6-Core Processor](https://de.pcpartp
22

r/CategoryTheory•

I've read the chapter on it in Milewski's book. However it was never mentioned what is the result of universal construction with a single object, and and two objects connected by a single morphism, so I tried to do it myself. I would like to make sure my reasoning is correct:

If I take a single object, then I get a cone c -> a, where c is an image of the constant functor and a the diagram, then there should be a morphism from every other candidate c' to c and from c' to a. So I have morphisms g: c' -> c, f: c -> a and h: c' -> a. So we are basically looking for a function f we can compose with any g, f . g, and that is the identity, so the limit is actually just a. So an univer

76

r/ocaml•

I'm making a parser generator and have a production type:

type t = {lhs: Symbol.t; rhs: Symbol.t list; properties: ?}

The problem is the type of the properties. The properties are additional information that tags along, it moves from production to items, from items to actions and then to the CST nodes. I want the user to be able to select any type, however if I do:

type 'props t = {lhs: Symbol.t; rhs: Symbol.t list; properties: 'props}

I have to add the type parameter everywhere and then can no longer make a set, because the type is now incompatible with the Set.OrderedType.

I guess I could make every module a functor that accepts the properties type, however I would again have to modif

14


r/haskellquestions•

https://ncatlab.org/nlab/files/WadlerMonads.pdf (3.2)

In what sense is "map g . map f" not equal to "map (g . f)"? What kind of inequality is that square thing? I'm guessing it has something to do with the reduction to WHNF and bottoms. Maybe because in one case you first reduce the argument to "map f" and then also reduce whatever "map f" returns, but in the second case you just reduce the argument to "map (g . f)", so in the first case the computation could fail at two places, but in the second at only one?

54

r/commandline•

I've been using this for a while and I thought I'd share.

I have a bunch of functions in .bashrc that open the configuration file and apply it of the form:

somethingrc() {
    nvim ~/.config/something/something && apply
}

A few examples:

bashrc() {
    nvim ~/.bashrc && . ~/.bashrc
}

nvimrc() {
    nvim ~/.config/nvim/init.vim
}

nixrc() {
    sudo nvim /etc/nixos/configuration.nix && sudo nixos-rebuild switch
}

You can then open the .bashrc, by just writing bashrc in the command line. If you don't want to apply the config you can exit with :cq.

419