-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Help architecting simple shell script replacement with polysemy #353
Comments
|
I can't see the second comment for some reason (only via e-mail) but if you have an interpreter like the one you mention hciPure :: (Member Trace r, Member HCI r) => HCIInstallStatus -> Sem (HCI ': r) a -> Sem r a It means it interprets Overall your approach is fine, ad 4 you can just compose spawn :: IO (Maybe (String, ExitCode))
spawn =
runFinal
. runTimeoutToIO @Seconds
. runProcessIOFinal
. runProcessOverSSH "localhost"
$ timeout 2 $ do
(i, o, e, h) <- createProcess "sleep" ["1"]
x <-
runOutputStream (Streaming.Prelude.toHandle i)
. runInputViaStream (Streaming.Prelude.fromHandle e)
. untag @"err"
. runInputViaStream (Streaming.Prelude.fromHandle o)
. untag @"out"
. stdStreamsAsInputOutput @String @"out" @"err"
. teletypeAsStdStreams
$ readTTY
e <- waitProcess h
return (x, e) Like @googleson78 suggests its probably better to desing higher level effects and implement these using lower-level ones. Meanwhile I'm working on hnix & hnix-store and trying to introduce Btw you can use |
I'm sorry that this got ignored for a year. If it's still relevant, I'm happy to review and respond. Closing now in an assumption that this is ancient stuff, but feel free to reopen --- I promise I'll respond! |
Edit: I tried to simplify this so it's easier to make suggestions.
I have a shell script I want to replace with polysemy, and it does the following:
codygman/hci
repo (emacs config, nixos config) locally to ~/hci~/hci/nixpkgs
to~/.config/nixpkgs
.home-manager
if it's not found bywhich
home-manager switch
to sync my nix configuration to this computerI originally had code here that covered steps 1-4, this code has been simplified to only cover step 3 since it's the simplest example of my confusion.
My questions:
installHomeManager
function betweenhomeManagerPure
andhomeManagerIO
interpreters so when I testhomeManagerPure
the logic ofhomeManagerIO
is also tested?maybeInstallHomeManager
,maybeSymlinkHCI
, andhomeManagerSwitch
how could I compose them together or alternatively sequence them all at once? Or is it best just to have arunM
for each one?Here is the code:
I'm aware of #28, #232, PolysemyCleanArchitecture, and sir4ur0n's intro to polysemy. I'm currently re-reading those resources and trying to understand them, reflect on the not quite working implementation I've got, and attempting to glean the "this is how you architect polysemy applications, this is too little granularity, this is too much granularity".
Edit: I reflected some more on the above resources I was aware of, nothing as of yet.
Thanks!
The text was updated successfully, but these errors were encountered: