Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. Design patterns
  2. Singleton | top-level creation in main, pass it in as a Reader
  3. Factory | Just don't export the contstructor, and do export a smart constructor
  4. Factory Method | Add a type parameter to your ADT
  5. Abstract Factory | Use an existential with a typeclass constraint (aka use a type lambda on the RHS of data decl)
  6. Builder | Add a type parameter to your ADT and add a function parameter to your smart constructor that describes your "special construction process"
  7. Prototype | Don't export constructor, do export *nullary* smart constructor
  8. Object Pool | > Non-optimizing compiler can't even do this for you smh
  9. Chain of Responsibility | Function composition, or some more powerful Monad instance if you need it
  10. Command | Make an ADT for the command
  11. Interpreter | Use Free Monads and Cofree interpreters :P
  12. Iterator | literally the Foldable typeclass
  13. Mediator | Write a typeclass to define the interaction, or use two Free monad DSLs if it is very complex
  14. Observer | >State
  15. Observer (multithreaded) | Use MVars, TVars, or Chans (which are just MVar pairs)
  16. Strategy | Write a typeclass
  17. Template Method | Write a typeclass, plus some default implementations
  18. Visitor | I don't know what this is, but it looks like a Functor
  19. Null Object | Use one of: Either, Maybe, MonadFail m => m
  20. Adapter | Write a newtype and a give it a compatible instance
  21. Bridge, Composite | Category, Arrow, or Lens depending on what you need
  22. Decorator | Write a typeclass instance (I think)
  23. Flyweight | > Mutability. Nice meme
  24. Memento | Just write a function (YourObject -> StateRepr)
  25. Proxy | This is possible, but super contrived and useless in Haskell, so just don't use it
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement