小编Mat*_*ing的帖子

计算索引免费monad类型的详细信息

我一直在使用免费的monad来构建DSL.作为语言的一部分,有一个input命令,目标是反映类型级别的输入原语所期望的类型,以增加安全性.

例如,我希望能够编写以下程序.

concat :: Action '[String, String] ()
concat = do
  (x :: String) <- input
  (y :: String) <- input 
  output $ x ++ " " ++ y
Run Code Online (Sandbox Code Playgroud)

随着评估功能

eval :: Action params res -> HList params -> [String]
eval = ...
Run Code Online (Sandbox Code Playgroud)

其中以下列方式工作..

> eval concat ("a" `HCons` "b" `HCons` HNil)
["a b"]
Run Code Online (Sandbox Code Playgroud)

这是我到目前为止所拥有的.

data HList i where
  HNil :: HList '[]
  HCons :: h -> HList t -> HList (h ': t)

type family Append (a …
Run Code Online (Sandbox Code Playgroud)

dsl haskell

15
推荐指数
4
解决办法
1402
查看次数

标签 统计

dsl ×1

haskell ×1