When using ADTs in our code base, it can be difficult to use common debugging tools like watches and breakpoints. This is mainly due to the common pattern of using compositions and other ways of manipulating how functions are called. This can cause us to have to revert to using console logs at the different points in our flow, to peek at how our data is changing over time. When using ADTs this gets even further complicated by the fact that we typically need ways to lift our logging functions into the type.

To get a handle on one way to approach debugging, we’ll look at a logAfter function that is a must in any Functional Programmer’s toolkit. Using logAfter we’ll hunt down a bug currently in our code base and once located, squash that bug out of existence.

// logAfter :: (a -> State s b) -> a -> State s b
export const logAfter = fn =>
composeK(liftState(tap(console.log)),fn)

How to use:

// validateAnswer :: String -> State AppState Boolean
const validateAnswer = converge(
liftA2(equals),
logAfter(getHint),
logAfter(cardToHint)
)

最新文章

  1. System.Json 使用注意
  2. 关于mysql登录异常处理方法 - mysql ERROR 1045 (28000)
  3. Python开发入门与实战17-新浪云部署
  4. css008 给网页添加图片
  5. 如何通过pid快速找出进程的路径
  6. c语言基础
  7. Java中必须了解的常用类
  8. Delphi 记录类型- 结构指针
  9. LINQ及EntityFramework何时从数据库返回数据,备忘
  10. python基础:os模块中关于文件/目录常用的函数使用方法
  11. 瑞昱Realtek(Realtek HD Audio Driver)音频声卡驱动R2.49 for Win7_Vista
  12. Html网页生成Pdf
  13. PropertyGird( 属性表格) 组件
  14. java基础之 第一步 :jdk安装配置
  15. Oracle总结【视图、索引、事务、用户权限、批量操作】
  16. 剑指Offer——线程同步volatile与synchronized详解
  17. .NET英文技术文章导读(2017-02-09)
  18. RDIFramework.NET ━ .NET快速信息化系统开发框架 V3.2->用户管理模块新增“重置用户密码”功能
  19. 入坑C++
  20. 2018-软工机试-E-热河路(TLE只拿了90分,待思考)

热门文章

  1. ubuntu16.04编译安装GPAC
  2. 最小生成树算法详解(prim+kruskal)
  3. 关于在windows下部署发布QT程序的总结
  4. UVA 548.Tree-fgets()函数读入字符串+二叉树(中序+后序遍历还原二叉树)+DFS or BFS(二叉树路径最小值并且相同路径值叶子节点权值最小)
  5. Flask实战第47天:首页导航条首先和代码抽离
  6. 【JavaScript】JS将Java的Timestamp转为Date类型
  7. 在spring中手动编写事务
  8. [BZOJ4836]二元运算(分治FFT)
  9. Codeforces 741B Arpa's weak amphitheater and Mehrdad's valuable Hoses
  10. JDK源码学习笔记——HashSet LinkedHashSet TreeSet