Skip to content

Add getEnvironment#6166

Draft
japgolly wants to merge 2 commits intounisonweb:trunkfrom
japgolly:getEnvironment
Draft

Add getEnvironment#6166
japgolly wants to merge 2 commits intounisonweb:trunkfrom
japgolly:getEnvironment

Conversation

@japgolly
Copy link

@japgolly japgolly commented Feb 7, 2026

Overview

Fixes #6165

Implementation approach and notes

I'm just trying to follow what was done for getEnv and getArgs

Test coverage

Pending

Loose ends

N/A

Final checklist

  • Choose your PR title well: Your pull request title is what's used to create release notes, so please make it descriptive of the change itself, which may be different from the initial motivation to make the change.
  • Update your PR description if the specifics of the PR have changed over time.
  • Include transcripts or screenshots that demonstrate the changed behavior.
  • If you changed .cabal files, make sure the package.yaml files are up-to-date instead.

@japgolly
Copy link
Author

japgolly commented Feb 7, 2026

Is anyone able to help me with this?

  1. When I run stack exec unison it doesn't recognise the new method.
main : '{IO, Exception} ()
main = do
  printLine "hello"
  printLine (getEnv "HOME")
  printLine getEnvironment()

results in

  I couldn't figure out what getEnvironment refers to here:
  
      5 |   printLine getEnvironment()
  
  I found a term in scope with a similar name but a different type. Was this what you wanted?
  
  getAndIncrement : Ref {IO} Nat ->{IO} Nat
  1. I want to add tests to io.md but I don't know how to get unison running in such a way that that code works. For example where does the io2.IO ability come from. Apologies if this is obvious but I've only started learning Unison this week 😅

@skykanin
Copy link

skykanin commented Feb 9, 2026

Is anyone able to help me with this?

1. When I run `stack exec unison` it doesn't recognise the new method.
main : '{IO, Exception} ()
main = do
  printLine "hello"
  printLine (getEnv "HOME")
  printLine getEnvironment()

results in

  I couldn't figure out what getEnvironment refers to here:
  
      5 |   printLine getEnvironment()
  
  I found a term in scope with a similar name but a different type. Was this what you wanted?
  
  getAndIncrement : Ref {IO} Nat ->{IO} Nat
2. I want to add tests to `io.md` but I don't know how to get unison running in such a way that that code works. For example where does the `io2.IO` ability come from. Apologies if this is obvious but I've only started learning Unison this week 😅

You need to give the new built-in a name. This should be done in base, but if you want to test it locally you can use the alias.term command in ucm. alias.term ##IO.getEnvironment.impl.v1 IO.getEnvironment. Then you should be able to reference it in your code as IO.getEnvironment.

@japgolly
Copy link
Author

Thanks @skykanin . I'm able to see the see the changes locally now!

Remaining Problems

  1. How do I add the new function to base?
  2. Running stack exec unison transcript unison-src/transcripts/pretty-print-libraries.md wipes out the changes I made by hand to pretty-print-libraries.output.md.
  3. Running stack exec unison transcript unison-src/transcripts-using-base/all-base-hashes.md fails with an error saying No results..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose getEnvironment :: IO [(String, String)]

2 participants