- Crappy record system: no constructor/field overloading, no dot syntax, no row polymorphism
Crappy module systemThere's backpack, apparently- CPP -- this could be solved by pragmas
- Crappy dependent type support
- Boilerplate & Code duplication
- No totality checking
- Crappy type system (Type :: Type, Weak type-level functions)
- Barely usable typed holes, extreamly bad editor integration
- Weird behaviors when checking GADTs
- Over restrictive typeclass resolution (no backtracking, crappy termination checking leading to unnecessary use of UndecidableInstances)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Copyright (c) 2010 Timothy J Fontaine <tjfontaine@atxconsulting.com> | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is |
上篇文章简单的介绍了一下 Haskell (GHC) 提供的 user-level concurrency primitives, 这篇将介绍 Haskell 的异常与资源管理。本文默认读者对其他语言中的异常有一定了解。
众所周知,处理异常是非常 impure 的(这里将 purity 定义为 confluence modulo exceptions and non-terminations), 而且 haskell 已经有处理异常的方式了: Either
与 ExceptT
, 为什么还需要加入 exception 呢?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE AllowAmbiguousTypes #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE UndecidableInstances #-} |
When the limestone of imperative programming has worn away, the granite of functional programming will be revealed underneath -- Simon Peyton Jones
虽然 Haskell 拥有丰富而成熟的并发特性,但在平时交谈时这些特性似乎很少被提到。因此我想通过 Concurrency 系列文章从用户角度科普一下 Haskell 的并发编程的特性 (先从 User-level concurrency primitives 讲起)。本文将默认读者对 Haskell 和并发编程有基本的了解。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE AllowAmbiguousTypes #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE InstanceSigs #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE PolyKinds #-} | |
{-# LANGUAGE RankNTypes #-} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is a draft for a future blog post and might be deleted at any time. | |
Audiances are assumed to be familiar with the c2hs library and Haskell c ffi and have basic knowledge of c. | |
1. Overall design | |
I would suggest to do a two-layer design, that is one-level for binding and basic marshalling and one-level for abstraction. | |
2. Representing C datatypes in Haskell | |
When designing FFI, you almost always need to represent C datatypes as some Haskell datatypes. You'll need to further add Storable | |
instance for that Haskell type if you need to marshal between C and Haskell. Associating a C type with Haskell is relatively easy | |
with c2hs so I'll only cover the marshalling part. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is my philosophical argument on why functional programming matters. | |
1. Abstraction | |
Functional programming unlocks a whole varieties of abstractions (monads, arrows and profunctors for example) that are meaningless to | |
mimic or impractical and unable to implement in imperative languages. These abstractions help us to tackle and understand a complex | |
software system to effectively reduce the complexity | |
(insert notation as a tool of thought citation) | |
2. Constraints | |
Funcitonal programming let us specify what exactly a program can do and cannot do -- type signatures, class constraints, dependent types, |