adrien changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.09 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.09/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
malc_` has joined #ocaml
zebrag has joined #ocaml
inkbottle has quit [Ping timeout: 240 seconds]
malc_` has quit [Quit: ERC (IRC client for Emacs 28.0.50)]
malc_ has joined #ocaml
ollehar has quit [Ping timeout: 240 seconds]
ollehar has joined #ocaml
mnxn has quit [Quit: mnxn]
malc_ has quit [Ping timeout: 260 seconds]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 260 seconds]
mnxn has joined #ocaml
waleee-cl has quit [Quit: Connection closed for inactivity]
malc_ has joined #ocaml
quarters has quit [Changing host]
quarters has joined #ocaml
narimiran has joined #ocaml
vicfred has quit [Quit: Leaving]
mnxn has quit [Ping timeout: 258 seconds]
mnxn has joined #ocaml
mbuf has joined #ocaml
quarters has quit [Ping timeout: 240 seconds]
mnxn has quit [Quit: mnxn]
osa1 has joined #ocaml
mnxn has joined #ocaml
mnxn has quit [Quit: mnxn]
quarters has joined #ocaml
quarters has quit [Ping timeout: 260 seconds]
Haudegen has joined #ocaml
<defolos> Fardale: the script will be run in an isolated environment without a proper user set up and without an internet connection
<defolos> so running opam init there will probably cause more problems
<swapnilraj[m]> quarters: you can use explode, `val explode : string -> char list`, then you can just use match like you do with list
fff has joined #ocaml
fff has quit [Remote host closed the connection]
olle has joined #ocaml
<Fardale> defolos: how can you get the opam file if you don't have an internet connection?
<ebb> USB flash?
<defolos> Fardale: I already have the tarbal (it's for creating rpm packages, the tarball of the sources is already present, but no internet connection)
<Fardale> Then I don't get what you want. opam work with the opam-repository, if you don't have internet connection then you will not be able to use opam
<def> Fardale: you can setup opam with only a local repository I think.
<Fardale> I think also, but it will use a local opam repository, not the package repository
<def> Yep, so one has to clone the package repository locally first.
<def> (And play with tarball caching to avoid redownloading package contents? ...)
<def> opam is probably not really suitable for this task
<Fardale> I think defolos is looking for something that read opam file
<theblatte> "opam admin cache" is your friend
<theblatte> since opam2 making an offline opam repo is easy
<Fardale> And it seems easier to me to extract the information in the opam file than to set up all you need for opam to work
mnxn has joined #ocaml
<defolos> Fardale: exactly, I just want to get the build dependencies out of the opam file so that I can convert them to a format that rpm understands and potentially at a later point also extract the build instructions
<defolos> so I really don't need any opam repositories setup or what not, I just need to parse the opam file
malc_ has quit [Ping timeout: 240 seconds]
<Armael> you might want to look how https://github.com/timbertson/opam2nix does it
<Armael> you could write a simple tool using the opam libs, if that doesn't exist already
<defolos> Armael: oh, that's nifty! Thanks a lot!
<defolos> I'll definitely take a look at that
<Armael> simply *parsing* a .opam file is relatively easy, using the "opam-file-format" library; however you just get an AST. To be robust wrt evolutions of the .opam format, you might want to look for another representation where the file contents have been "interpreted" as a description of a package
malc_ has joined #ocaml
mnxn has quit [Quit: mnxn]
zebrag has quit [*.net *.split]
dmbaturin_ has quit [*.net *.split]
infinity0 has quit [*.net *.split]
Serpent7776 has quit [*.net *.split]
porchetta_ has quit [*.net *.split]
oturtle has quit [*.net *.split]
vesper11 has quit [*.net *.split]
Guest85141 has quit [*.net *.split]
wagle has quit [*.net *.split]
Serpent7776 has joined #ocaml
dmbaturin_ has joined #ocaml
infinity0 has joined #ocaml
oturtle has joined #ocaml
porchetta_ has joined #ocaml
Guest85141 has joined #ocaml
zebrag has joined #ocaml
wagle has joined #ocaml
vesper11 has joined #ocaml
zebrag has quit [Max SendQ exceeded]
zebrag has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
quarters has joined #ocaml
malc_ has quit [Remote host closed the connection]
quarters has quit [Ping timeout: 240 seconds]
ggole has joined #ocaml
Haudegen has joined #ocaml
dborisog has joined #ocaml
delysin has quit [Quit: WeeChat 2.8]
malc_ has joined #ocaml
dborisog has quit [Ping timeout: 260 seconds]
narimiran has quit [Ping timeout: 260 seconds]
oturtle_ has joined #ocaml
vicfred has joined #ocaml
oturtle has quit [Ping timeout: 240 seconds]
dckc has quit [Ping timeout: 272 seconds]
dckc has joined #ocaml
jco has joined #ocaml
malc_ has quit [Ping timeout: 265 seconds]
waleee-cl has joined #ocaml
jco has quit [Ping timeout: 240 seconds]
zv has joined #ocaml
jco has joined #ocaml
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 256 seconds]
osa1 has quit [Ping timeout: 265 seconds]
muskan has joined #ocaml
olle has quit [Remote host closed the connection]
sagax has quit [Read error: Connection reset by peer]
brown121407 has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
AdmWiggin is now known as tianon
sagax has joined #ocaml
malc_ has joined #ocaml
osa1 has joined #ocaml
haesbaert has quit [Remote host closed the connection]
jco has quit [Quit: WeeChat 2.7]
Haudegen has joined #ocaml
osa1 has quit [Quit: osa1]
quarters has joined #ocaml
mbuf has quit [Quit: Leaving]
mnxn has joined #ocaml
quarters has quit [Ping timeout: 246 seconds]
quarters has joined #ocaml
remexre has quit [Read error: Connection reset by peer]
remexre has joined #ocaml
<ollehar> I want to find a design pattern that removes all side-effects from business logic
<companion_cube> state machines, encoded as sum types?
<ollehar> so that the database connection is never injected
<ollehar> companion_cube: can you elaborate?
<companion_cube> represent your logic as functions `state -> state`
<ollehar> right now I'm using the pipeline pattern, a list of "callables"
<companion_cube> where state is a purely functional structure?
<ollehar> companion_cube: yes, the state (or "payload" as it's called in pipelines) has to be explicit
<ollehar> companion_cube: hm, what does "purely functional" mean?
<companion_cube> no mutation?
<ollehar> ah
<ollehar> OK, so if you want to call the database and switch/match on the result?
<ollehar> right now I have `return new Query('SELECT bla bla bla');`
<companion_cube> I guess you can have `state -> state * operation list`, then you run the DB operations
<companion_cube> and you feed that back to your pure world?
<companion_cube> there are examples in opam, libs that do this kind of stuff for network protocols
<ollehar> yeah? :)
<ollehar> yeah, returning a tuple sounds like a good idea!
* ollehar takes notes
<ollehar> phew, I ask these kind of questions in ##php and they ban me -.-
<ollehar> the only thing that can never work in this pattern is in-function logging, but that's OK
<ollehar> or, you just split your functions to be really small
<companion_cube> I mean, why would you do that in php? it's not particularly functional , is it?
<ollehar> companion_cube: no, but side-effects mess up testability
<ollehar> and mocking database connections is not very practical
<companion_cube> 🤷
<companion_cube> tell them that?
<ollehar> can't read emojis, sorry.
<ollehar> shrug?
<companion_cube> yep
<ollehar> hm
<ollehar> I assume they'll say - again - that I'm raping the language
<companion_cube> seems like a toxic channel
<ollehar> idk
<ollehar> getting pretty tired of the php community lately
muskan has quit [Remote host closed the connection]
narimiran has joined #ocaml
Serpent7776 has quit [Ping timeout: 240 seconds]
haesbaert has joined #ocaml
Serpent7776 has joined #ocaml
quarters has quit [Changing host]
quarters has joined #ocaml
malc_ has quit [Ping timeout: 265 seconds]
mnxn has quit [Quit: mnxn]
aaaaaa has joined #ocaml
<ollehar> state * operation list does not work for me
<ollehar> it leaves me with the same situation as before - having to mock the database connection
<ollehar> adding new operations while traversing the operation list has to go
<ollehar> grrrr
<ollehar> it's easy to do multiple filters on the pipe payload, but impossible to do switch or `if`
<ollehar> unless you invent a new DSL
<companion_cube> well, use a monad, I guess?
<ollehar> in PHP? :D
<companion_cube> idk, really
<ollehar> i know, i know
<ipavlo> May be then try to use tree instead of list? Well, that looks like DSL but not THAT far from what you have now
<ollehar> ipavlo: yes, exactly
<ollehar> I also tried with a SideEffectFactory class.
<ollehar> I wonder if it's easier to mock such a class than a database connection (file connection, stdout connection, etc etc)
<ollehar> I'd like to see my CTO's face when he looks at my monadic PHP code in our hosting code base xD
<ipavlo> Looks like a missed something, but do you really need to mock database connection? You can use some kind of OOP repository pattern and mock only simple interface
<ollehar> yeah, repositories is how the latest frameworks do it
<companion_cube> (what's a repository pattern?)
<ollehar> wish i knew
<ollehar> you separate the model from the storage, i think
<ollehar> database -> storage -> model object
<ipavlo> Here pretty good explanation, but with C#, should be pretty clear
<companion_cube> oh so it's like an ORM?
<ollehar> hm, not what I thought of, actually
<ipavlo> Not exactly. You hide DB operations behind some interface. Interface deals with simple entities- in Java/C# the are called POJO/POCO (Plain Old Java (C#) Objects).
<ipavlo> These POCOs do not have any behavior- just entities that participate in your Business Logic. So, repository takes data from DB(using any underlying mechanism- ORM or clear DB connections) and transforms to something that is closer to your business logic
<companion_cube> I imagine the objects have some sort of internal ID that maps to the DB row, or something?
<companion_cube> if you want to perform updates
<ipavlo> In ORM - yes you have some mapping. But you not necessarily need it in case of repository.
<ollehar> splitting hairs :D
<ollehar> in essence: it's another indirection ;)
<ipavlo> Imagine, you do query to DB, than you transform to some record like {id: int; name: string; last_name: string}. This entity has no direct connection to DB. Its just Data. You do some logic - e.g. change Name. Then you must call repository#save entity. Your repository transforms it to request like Update lala Set name =entity.name where id=entity.id
<companion_cube> well, it's connected to the DB implicitly :p
<ipavlo> In case of OOP this pattern has no connection with DB - its just plain objects and methods. Implementation- of course yes, it must have some connection:)
aaaaaa has quit [Ping timeout: 240 seconds]
<ollehar> isn't putting side-effect objects into a monadic bind more or less the same as putting them in a list of callables?
<ollehar> not sure monads would change much here :d
<ollehar> in terms of "easy to do mocks"
narimiran has quit [Ping timeout: 256 seconds]
ggole has quit [Quit: Leaving]
sagax has quit [Ping timeout: 260 seconds]
sz0 has quit [Quit: Connection closed for inactivity]
nicoo has quit [Remote host closed the connection]
nicoo has joined #ocaml
Haudegen has quit [Ping timeout: 256 seconds]
cthuluh has quit [Ping timeout: 264 seconds]
cthuluh has joined #ocaml
quarters_ has joined #ocaml
quarters has quit [Read error: Connection reset by peer]