You are probably right. I probably do need to drop a level.
Since yours and @dom96 replies I have experimented some more.
I have tried catching, TimeoutError, IOError, OSError. I have reduced the
timeout in the HttpClient to 500millis.
Sometimes it catches the errors. Sometimes none show up in
Incorrect, @mratsim definitely put generic in there, meant, the type T that you
should make it variant or heterogeneous.
Also considering with your example about @[messageType, messageId, rpc_method,
arguments]
It should have a structure like this
type
MyHeterogeneousVals =
It's probably specific to your code, so a code paste would be helpful.
You gave the HgCells in HgPacks a fix data type - because of this, it's not
heterogeneous anymore. You shouldn't remove the concept because it should be a
constraint on the types at the procedures.
I think you need to define at which level your list is heterogeneous.
If you have a seq[T] with T being a runtime type, you have to use type erasure,
either through object variants or through inheritance.
Here is your example fixed. Now you can just transform the Packet type into an
object vari
@mashingan no, 'msgpack-nim' is a dead project, the author is waiting for nim
1.0. 'msgp4nim' is probably just an experiment - it can't do what I want and
it's also failing for basic cases(I started to use this first but I experienced
a lot of issues). The two other projects are based on msgpack
Trying to write and read `IpAddress` from/to disk via `readData(x.addr,
x.sizeof)` and `write(x)` seems to be flakey when both Ipv4 and IPv6 addresses
are used. Using IPv4 alone seems to work.
Also, (using Nim 0.19.1/linux) I can't set the `address_vX` fields of
`IpAddress` ("cannot prove ... f
@trtt, I've covered heterogeneous containers and how to do type erasure in
reply to @kcvinu threads here:
* [Is there any untyped list datatype in
Nim](https://forum.nim-lang.org/t/4233#26367)
* [Need help for a generic object
field](https://forum.nim-lang.org/t/4406#27516)
In case you want to give it a spin, nlvm has had some wasm support for some
time now: [https://forum.nim-lang.org/t/3758](https://forum.nim-lang.org/t/3758)
there's a new llvm version in place since that post which should hopefully be
an improvement, but do let me know if you have any success or
@trtt You can add such a constraint with `T: HList` if you want. It seems not
to work very well now, maybe I will try to figure out why.
But there is another point which is important. You **do not** lose the generic
type information if you don't specify T. This is because the type checking and
The available packages don't answer your problem?
[https://nimble.directory/search?query=msgpack](https://nimble.directory/search?query=msgpack)
@trtt I thought I gave you example, but anyway, it's here
[https://github.com/mashingan/nim-etc/blob/master/cond_loop.nim](https://github.com/mashingan/nim-etc/blob/master/cond_loop.nim)
I don't have the code yet because I'm about to write it(actually, I've a very
different code but the problem is that I need the timeout mechanism, otherwise
the program can't cooperate properly). But I'll quote my problem again:
"I need this to be able to communicate with another program in a si
@andrea your HList/hkCons's tail has type T which means you can't be sure that
it's a HCons - you'll lose the generic type information too and can't apply
type inference anymore.
@mratsim my lists are always heterogeneous
@alehander42 let me explain the problem:
I'm trying to create a flexible
I don't know details of your application, but...
What you could do is store the `FlowVar` (the object that spawn returns) for
the thread that is waiting for stdin, wait for the FlowVar to finish for
timeout seconds. If it finishes before timeout then use the returned value and
re-spawn the thre
Ok, but I need a timeout too, non-blocking stdin is not enough.
**I don 't want a vote**, but I want more rationalization behind the feature. I
like the feature, but I can see that a lot of people are afraid of its effects
in corner cases.
The article should explicitly tell that style insensitivity is rarely used and
state the cases when it should be. In fa
If your list is not heterogeneous, you can just implement it like in
[nimfp](https://github.com/vegansk/nimfp/blob/master/src/fp/list.nim#L10-L20)
type
ListNodeKind = enum
lnkNil, lnkCons
List*[T] = ref object
## List ADT
case kind: ListNodeKind
`stdin` will block a whole thread (this is not nim specific), so you need to
spawn a reader thread to read from stdin, async will not work.
Note that how to read from `stdin` in a non-blocking way seems to be a popular
question on Google search as there are Gevents, Python, D, Rust, Vala and
Ha
Also, you can use converters:
[https://nim-lang.org/docs/manual.html#converters](https://nim-lang.org/docs/manual.html#converters)
I'd do
type
HList[T] = ref object
case kind: HListKind:
of HNil: discard
of HCons: head: T; tail: HList[T] # on two lines in real code
HValue = ref object
case kind: HValueKind:
of HInt: i: int
of HString: text: st
@trtt Apart from using solutions for pattern matching such as gara, you can
iterate recursively over HLists and use if/case statements
This is how I would write a barebone HList, but for some reason the recursive
printAll does not seem to work
type
HListKind = enum hkNil, hkC
My last 2 "solutions" don't work either because for the first one I'd need a
proper nominal abstraction feature(or how to store a concept in a seq when the
elements can be different) and for the second one I'd need existential types(or
how to tell the that a seq can hold a HeterogenCell with any
Interesting problem!
Variants _are_ basically sum types in Nim.
Yeah, I was wondering similar things for some projects.
I am not sure what are you using hlists for, is it an AST. To represent an AST
you don't really need anything more complicated than data types(variants) in
Nim: HList.Cons ca
How would you instruct it to quit if it's blocked by stdin?
25 matches
Mail list logo