Skip to Content.
Sympa Menu

maude-help - [Maude-help] Type synonyms

maude-help AT lists.cs.illinois.edu

Subject: Maude-help mailing list

List archive

[Maude-help] Type synonyms


Chronological Thread 
  • From: Cezar Ionescu <ionescu AT pik-potsdam.de>
  • To: maude-help AT maude.cs.uiuc.edu
  • Subject: [Maude-help] Type synonyms
  • Date: Tue, 11 Aug 2009 20:34:48 +0200
  • List-archive: <http://maude.cs.uiuc.edu/pipermail/maude-help>
  • List-id: Maude help list <maude-help.maude.cs.uiuc.edu>

Hello everybody,

I'm trying to write a small three-agents program in Maude. The agents
have stocks of goods, they work, they get paid in goods per labour,
etc. I've already implemented this in Haskell, and I've found it useful
to use type synonyms, i.e., although goods and labour are represented as
floats, I'd like the operators to act on sorts called GoodsStocks and
LabourFlow, and the like. Is there a simple way to do that in Maude?

I've already written things like

sorts GoodsStock LabourFlow .
op gs_ : Float -> GoodsStock [ctor] .
op toFloat : GoodsStock -> Float .
var F : Float .
eq toFloat (gs F) = F .

and so on. This corresponds to Haskell's ``newtype'' mechanism, and I
find the resulting program ugly. I've also tried renaming Float, but
that only seems to work once per module...

Anyway, thanks for the help. I have to say I find Maude the strangest
language I've programmed in so far, and I like it!

Best,
Cezar.




Archive powered by MHonArc 2.6.16.

Top of Page