いわゆる Haxe の enum というやつ。 これがないとプログラミングできない。
たとえば、
assert = require('chai').assert, (verify = require('./../src/leathershield').verify, describe('type verifier', function () { | |
return it('verifies a string', function () { | |
return result = verify({ 'type': 'String' }), (assert.property(result, 'Simple'), assert.equal(result.Simple, 'string')); | |
}); | |
})) |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE OverloadedLists #-} | |
{-# LANGUAGE MultiWayIf #-} | |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE ViewPatterns #-} | |
{-# LANGUAGE NamedFieldPuns #-} | |
module Language.LeatherScript.Parser where |
$ tsc a.ts | |
/Users/pasberth/Library/Gentoo/usr/lib/node_modules/typescript/bin/lib.d.ts(10729,11): error TS2143: Interface 'SVGComponentTransferFunctionElement' cannot extend interface 'SVGElement': | |
Types of property 'type' of types 'SVGComponentTransferFunctionElement' and 'SVGElement' are incompatible. | |
/Users/pasberth/Library/Gentoo/usr/lib/node_modules/typescript/bin/lib.d.ts(10873,11): error TS2143: Interface 'SVGFETurbulenceElement' cannot extend interface 'SVGElement': | |
Types of property 'type' of types 'SVGFETurbulenceElement' and 'SVGElement' are incompatible. | |
/Users/pasberth/Library/Gentoo/usr/lib/node_modules/typescript/bin/lib.d.ts(10905,11): error TS2143: Interface 'SVGFEColorMatrixElement' cannot extend interface 'SVGElement': | |
Types of property 'type' of types 'SVGFEColorMatrixElement' and 'SVGElement' are incompatible. |
{-# LANGUAGE JavaScriptFFI #-} | |
import GHCJS.Foreign | |
import GHCJS.Types | |
import Control.Applicative | |
foreign import javascript unsafe "document.getElementById($1).innerHTML" js_unsafeGetElementById :: JSString -> IO JSString | |
main = do | |
str <- fromJSString <$> js_unsafeGetElementById (toJSString "hoge") |
事前に、GHC 7.8.1 が必要です
$ git clone git@github.com:ghcjs/cabal.git cabal-ghcjs
$ git clone git@github.com:ghcjs/ghcjs.git
$ cd cabal-ghcjs
$ git checkout ghcjs
# ``cabal install ./Cabal ./cabal-install'' だと cabal が上書きされてしまう。
# ``--program-suffix=-ghcjs'' をつけると cabal-ghcjs という名前でインストールされる
type 'a show = [`Show of (string * 'a)] | |
type my_int = [`Show of (string * int)] | |
type my_float = [`Show of (string * float)] | |
type my_str = [`Show of (string * string)] | |
let show (`Show (pretty, x) : [< `Show of (string * 'a) ]) = pretty | |
let print x = print_endline (show x) | |
let mk_my_int x = `Show((string_of_int x), x) |
WITH BOM: | |
757: unexpected token at '{"api_result":1,"api_result_msg":"\u6210\u529f","api_data":[{"api_id":9,"api_maparea_id":2,"api_name":"\u30bf\u30f3\u30ab\u30fc\u8b77\u885b\u4efb\u52d9","api_details":"\u6cb9\u7530\u5730\u5e2f\u304b\u3089\u71c3\u6599\u3092\u6e80\u8f09\u3057\u3066\u623b\u308b\u30bf\u30f3\u30ab\u30fc\u8239\u56e3\u3092\u8b77\u885b\u3057\u3088\u3046\uff01","api_time":240,"api_difficulty":3,"api_use_fuel":0.5,"api_use_bull":0,"api_active":1,"api_state":2,"api_win_item1":[10,1],"api_win_item2":[1,2]},{"api_id":10,"api_maparea_id":2,"api_name":"\u5f37\u884c\u5075\u5bdf\u4efb\u52d9","api_details":"\u6c34\u4e0a\u5075\u5bdf\u6a5f\u642d\u8f09\u8266\u306a\u3069\u3092\u6d3b\u7528\u3057\u3001\u6575\u8266\u968a\u306e\u52d5\u5411\u3092\u63a2\u308c\uff01","api_time":90,"api_difficulty":3,"api_use_fuel":0.3,"api_use_bull":0,"api_active":1,"api_state":2,"api_win_item1":[1,1],"api_win_item2":[2,1]},{"api_id":11,"api_maparea_id":2,"api_name":"\u30dc\u30fc\u30ad\u30b5\u30a4\u30c8\u8f38\u9001\u4efb\u52d9","api_d |
test