haskell

code17 的头像

FP Job: Haskell/Ocaml developer (NY, US)

Leading US based Hedge Fund requires Haskell/Ocaml developer - NYC, New York, USA - Excellent compensation

Our client is one of USA's foremost Hedge funds, currently looking to expand its New York systems development team.

Ideal candidates profile:

  • Good understanding of both Haskell and Ocaml
  • Unversity level education in Computer Science or Engineering
  • Excellent communication skills
  • No finance experience necessary
  • Candidates should be eligible to work in the US

Our client is not looking to relocate candidates currently based outside of the US. (see below)

chylli 的头像

yi editor notes

基本上例子都是从http://www.nobugs.org/developer/yi/抄下来的,但有些修
改,因为yi的变化比较大.

不敢乱开book了,又没信心持续写下去。所以就发这里了.

首先是安装 yi editor,现在的版本需要ghc 6.10.1, 库也要比较新的才好.

不过我发现几个大bug,也不知道怎么的,现在还没修复,不知道啥时候有戏。自
己本领又有限,唉.凑合着用吧.

我用的是archlinux, 几大bug分别为:
1. vty界面下中文(多字节字符)显示不正常。
2. gtk下无法输入中文
3. gtk下load进新文件后buffer显示还是老buffer的内容
4. alt-key 会产生 esc + key序列,而且是随机的.

基于以上四点,简直没法用了。不过作为一个平台来写些小东西还是可以的.

对于第4点,可以用最新的vty包,并将 Yi/UI/Vty.hs里的
v <- mkVty 换成 v <- mkVtyEscDelay 1000.

不明白为啥它还不放进darcs里面.

安装完后,将源文件里的 example/yi.hs copy到 ~/.yi下,然后就可以启动yi了:

yi -f vty

太晚了,明天接着写吧

chylli 的头像

haskell要背诵的代码

--1. monad class的定义
class Monad m where
    (>>=) :: m a -> (a -> m b) -> m b
    (>>)  :: m a -> m b -> m b
    return :: a -> m a
    fail  :: String -> m a
    -- Minimal complete definition
    m >> k = m >>= \_ -> k
    fail s = error s

--2. monad 三定律的定义
(return x) >>= f == f x
m >>= return == m
(m >>= f) >>= g == m >>= (\x -> f x >>= g)

--3. monad plus的定义
class Monad m => MonadPlus m where
    mzero :: m a
    mplus :: m a -> m a -> m a

-- 4. id monad的定义
newtype Identity a = Identity { runIdentity :: a }

code17 的头像

FP Job: Senior Developer (Portland, OR, US)

Posted Date : Dec-01-08
Location : Portland, OR
Experience Level : Senior
Pay Rate : Market
Duration : Permanent

code17 的头像

ML 趣题:树的类型

这道也是老题了。(下面我们用OCaml作代码示例,SML或Haskell完全类似。)

  • 请用 Leaf 和 Node 这两个 constructors (i.e., variants) 来定义一个二叉树类型,使得以下表达式 number 和· tree 可以通过类型检测
  • 写出在这种定义下 number 的具体类型,并解释为什么
let rec number = function
  | Leaf _ -> 1
  | Node (_, tl, tr) -> 1 + number tl + number tr;;

let tree =
  Node ( [1;2;3] ,
         Node ( "function" ,
                Leaf None,
                Node ( succ,
                       Node ( Some 'c',
                              Node ( 3.1415,
                                     Leaf [],
                                     Leaf abs ),
                              Leaf "leaf" ),
                       Leaf [99] ) ),
         Leaf (log 10.)
       );;