Skip to content

How should I avoid cyclic dependency between application state and asynchronous worker? #472

Closed Answered by jtdaugherty
amano-kenji asked this question in Q&A
Discussion options

You must be logged in to vote

Oh, I see - you didn't mention module dependency in your original post. There are three approaches that come to mind for me:

  1. Use an .hs-boot file to make the circular dependency compile. This is a good approach when the modules involved must not be combined for some reason, but I personally try to avoid boot files unless there's no better way.
  2. Combine the data type declarations in one module so that they aren't spread out in a way that causes the mutual module dependency. This is a really common approach, e.g. make MyPkg.Types, put the types in there, then import MyPkg.Types in both of the modules that would have otherwise depended on each other.
  3. Abstract some of the data types in a way …

Replies: 1 comment 11 replies

Comment options

You must be logged in to vote
11 replies
@amano-kenji
Comment options

@jtdaugherty
Comment options

Answer selected by amano-kenji
@jtdaugherty
Comment options

@amano-kenji
Comment options

@amano-kenji
Comment options

@jtdaugherty
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants