A DSL powered search engine for magic the gathering cards
Find a file
2023-05-07 11:37:32 +02:00
app Added a fetcher for data, added a lot more operators. Need to add a ReadMe on how this is used2 2023-04-30 18:48:50 +02:00
Config Fixed lazy file loading by only loading the database path when needed, and only ounce 2023-05-05 20:43:37 +02:00
data added data 2023-05-07 11:37:32 +02:00
src fixed Color 2023-05-07 11:35:19 +02:00
test initial commit 2023-03-16 15:54:10 +01:00
.gitignore added data 2023-05-07 11:37:32 +02:00
CHANGELOG.md initial commit 2023-03-16 15:54:10 +01:00
LICENSE initial commit 2023-03-16 15:54:10 +01:00
mtgsearch.cabal Broken reading of config file. Need to create som sort of singleton at start of app so we don't need to read the config file multiple times 2023-05-05 16:09:12 +02:00
package.yaml Broken reading of config file. Need to create som sort of singleton at start of app so we don't need to read the config file multiple times 2023-05-05 16:09:12 +02:00
README.md Added most operations to ReadMe 2023-04-30 19:15:40 +02:00
Setup.hs initial commit 2023-03-16 15:54:10 +01:00
stack.yaml initial commit 2023-03-16 15:54:10 +01:00
stack.yaml.lock initial commit 2023-03-16 15:54:10 +01:00

mtgsearch

Developement of a custom magic card search engine.

DSL

Will be a language based in set theory, where queries can be combined, negated etc etc. Example.

I had to simplify the DSL a lot in order to have time. I have never written a lexer or parser before. So doing that in a language i am not that familiar with (haskell) proved to be quite difficult. Therefore in this section i will relay exactly how this DSL works.

It essentially is a Query Language, with similar properties as SQL. (It uses SQL at the bottom layer). So we have split the two Sets we can to into the following.

Query

A query is a very simple way of saying, limit all the cards in magic the gathering with the set limitation. Example there exists a Query function SuperType that takes in a string. This function will then match all cards type_line and return only those containing a match.

Operator

This is an operator between two sets. Example of an operator is the intersect operator. This takes two Sets and returns only the cards that exist in both. Example of a query using intersect:

(SuperType Creature) intersect (SuperType Legendary)

This query will only return Legendary Creatures, (Note: In theory you can write only (SuperType Legendary Creature) and it will return the same, however it is recommended to limit the SuperType search to only one word)

Avalible Query functions:

  1. (CmcLT Int)
    • This function will find all cards with converted mana cost less than the Integer provided as input
  2. (CmcMT Int)
    • This function will find all cards with converted mana cost more than the Integer provided as input
  3. (CmcEQ Int)
    • This function will find all cards with converted mana cost equal to the Integer
  4. (SuperType String)
    • This function will find all cards with the String value in its type_field.
    • NOTE: It is recommended to only use one word at a time and rather use set operators for better matching
  5. (Color Char)
    • This function allows to find all cards of specific color.
    • VALID INPUT: [W,R,G,B,U] where U = Blue and B = Black

Avalible Operators:

  1. left intersect right
    • This operator will give the intersect of whatever is to the left and right of it.
    • Example: (SuperType Creature) intersect (Color R) = All Red Creatures
  2. left union right
    • This operator will give the union of left and right
    • Example: (SuperType Creature) union (SuperType Instant) = All Creatures and Instants
  3. left minus right
    • This operator will give you all cards present in left but not in right
    • Example: (SuperType Creature) union (SuperType Legendary) = All non Legendary Creatures

Lexer

This languages lexer is very dumb. Therefore you the user has to be very verbose with your parenthesis. Example:

This will not work:

(IS Instant) union (Color Red) union (Color Green)

However this will

((IS Instant) union (Color Red)) union (Color Green)

The outer parenthesis is not needed, ex SuperType Creature is equivalent to (SuperType Creature)