Simplify readLayout, comment on surprising behavior

This commit is contained in:
Spencer Janssen
2007-09-25 21:17:08 +00:00
parent 68c72b34e1
commit 9c78ba538b

View File

@@ -144,9 +144,9 @@ instance Show (SomeLayout a) where
show (SomeLayout l) = show l
readLayout :: [SomeLayout a] -> String -> [(SomeLayout a, String)]
readLayout ls s = case concatMap rl ls of
(x:_) -> [x]
[] -> []
readLayout ls s = take 1 $ concatMap rl ls
-- We take the first parse only, because multiple matches
-- indicate a bad parse.
where rl (SomeLayout x) = map (\(l,s') -> (SomeLayout l,s')) $ rl' x
rl' :: Layout l a => l a -> [(l a,String)]
rl' _ = reads s