Skip to content

Pure use of this library #4

@passy

Description

@passy

Feel free to close this and point me to StackOverflow if this is too generic for the issue tracker. I hope I can verbalize my thoughts around this in a somewhat understandable manner.

I was wondering what the correct use of the library would look like with regards to the side-effecting behavior. In my app I took a shortcut and didn't quite realize what the implications of it were that looked like this when breaking it down:

data Input = { name :: String, ... }
data Entry = { id :: UUID, name :: String, ... }

makeEntry :: Input -> Entry
makeEntry inp = do
  let uuid = UUID.runUUID UUID.v4
  in
  { id: uuid, name: inp.name }

Afterwards I saw that I've created an impure function, even though the type signature doesn't give you any hint about it. Which brings me to my question: How would the library be used correctly for cases like this? What are the rules for the context to evaluate runUUID in?

When I try to apply my limited Haskell experience, the right way would be to carry the effect all the way through the chain to the main function, which in Haskell-land would be the only place where you could evaluate the IO type or the UUIDEff.

Does that make any sense?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions