mardi 14 mars 2017

What is the haskell equivalent of an interface?

I would like to implement modules that are guaranteed to export a similar set of functions.

For the sake of an example: Suppose I want to translate a word. Every word is mapped from the source language (let's say English) to the target language (let's say Spanish and Russian).

My main application would import the models for Spanish and Russian and chooses a default model, Russian. I would like to guarantee, that each model has:

  • a function translateToken :: String -> String
  • a function translatePhrase :: String -> String

in which the specific behaviour is implemented.

How do I do this?

Aucun commentaire:

Enregistrer un commentaire