@@ -15,8 +15,7 @@
16module Directive where
16module Directive where
18−import Control.Applicative
19−import Data.List (find, isPrefixOf)
18+import Data.List (isPrefixOf)
21data Directive
20data Directive
@@ -47,7 +46,10 @@ commands Show = ["show"]
47-- Tries to parse given string into a directive.
46-- Tries to parse given string into a directive.
49parseDirective :: String -> Maybe Directive
48parseDirective :: String -> Maybe Directive
50−parseDirective cmd = fst <$> find (matches . snd) mapping
49+parseDirective cmd =
50+ case filter (matches . snd) mapping of
51+ [directive] -> Just $ fst directive
52 mapping :: [(Directive, [String])]
54 mapping :: [(Directive, [String])]
53 mapping = zip directives (map commands directives)
55 mapping = zip directives (map commands directives)