blob: ce2119a582046db12a8959270403b78b022ed5eb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
ageOf architecture
ageOf determines somebody's age by querying one or more sources on the
Internet. Since there are hundreds of different sites that catalogue the ages
of famous (and not-so-famous) people, ageOf uses a plugin-based architecture.
Each source gets its own plugin, and then ageOf queries each source in turn.
The first source that gives back an age wins.
The Haskell idiom to do a plugin-based architecture is to define a plugin data
type, and that's what I've done here. The 'RequestMethod' type represents a
plugin--a single function that takes the name of a person and returns
(depending on which constructor you use) his/her age or date of birth. To
define a new plugin, you thus need to create a new module which exports a
'RequestMethod' type.
There are currently two plugins packaged with ageOf (though that may change in
the future). One is a sample plugin--it knows when Simon Peyton Jones (the
author of Haskell) was born, and that's it; use it as a skeleton for writing
your own plugins. The second plugin is a real, nontrivial plugin that uses
DBpedia (the Semantic Web mirror of Wikipedia) to determine the age of anybody
whose age is stored on Wikipedia.
Local Variables:
mode: text
fill-column: 79
End:
|