mwotton / Hubris

Bridge from Ruby to Haskell
shimweasel.com
260 stars 16 forks source link

Examples of passing Ruby hashes #27

Closed ghost closed 11 years ago

ghost commented 11 years ago

Hi,

Could you point to a simple example of passing in a Ruby hash?

Thanks.

mwotton commented 11 years ago

it's all in https://github.com/mwotton/Hubris/blob/master/spec/hubris_spec.rb

describe 'Hashes' do it "can move a Haskell map to ruby" do class HaskellMap hubris :inline => "import Data.Map ; h :: Int -> Map Int Int; h n = Data.Map.fromList $ zip [1..n] [n, n-1 .. 1]" end rh=HaskellMap.new.h(3) rh[3].should == 1 rh[2].should == 2 rh[1].should == 3 end

it "can move a ruby map to haskell" do class RubyMap hubris :inline => "import Data.Map; h :: Map Int Int -> Maybe Int; h m = Data.Map.lookup 10 m" end rb = RubyMap.new rb.h({8 => 100, 2 => 7}).should eql(nil) rb.h({10 => 100, 2 => 7}).should eql(100) end

end

On Mon, Jan 7, 2013 at 6:24 AM, Dan Serban notifications@github.com wrote:

Hi,

Could you point to a simple example of passing in a Ruby hash?

Thanks.

— Reply to this email directly or view it on GitHubhttps://github.com/mwotton/Hubris/issues/27.

A UNIX signature isn't a return address, it's the ASCII equivalent of a black velvet clown painting. It's a rectangle of carets surrounding a quote from a literary giant of weeniedom like Heinlein or Dr. Who. -- Chris Maeda