revati

revati

Determine type with NimbleParsec?

i want to parse string and determine if value is string/number/boolean/date/time/datetime/probably many more distinct value value types in future.

How to approach this. do i create parse for each separate option and than one choice?

But i have this caveat. for example for boolean, either it is word true or number 1 they can be casted to string or number respectively. Workaround for this might be, that seems ok from business point of view to have prefix or suffix, like boolean:1 or 1:boolean. and if this type casting prefix/suffix is present force that type for parser.

I don’t understand nimble parsec at that level, but i believe prefix is a lot easier (but still pretty hard - at least for me), but bossiness much rather would prefer suffix :expressionless:

someStringValue → string someStringValue
1 → integer 1
1.4 → float 1.4
1.4:string → string 1.4
1:boolean → boolean true

etc. If you have some hints, ideas how to approach this, i would greatly appreciate it.

Most Liked

LostKobrakai

LostKobrakai

I’d separate parsing the string to tokens of interest and then bringing those tokens together with whatever business logic you have around it.

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 55125 245
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New

We're in Beta

About us Mission Statement