String literals

Bulat Ziganshin bulat.ziganshin at gmail.com
Sat Nov 11 04:19:54 EST 2006


Hello Donald,

Saturday, November 11, 2006, 7:33:48 AM, you wrote:
> Yes, pattern matching is the issue that occurs to me too.
> While string literals :: ByteString would be nice (and other magic
> encoded in string literals,  I guess), what is the story for pattern
> matching on strings based on non-inductive types like arrays?

it's my day :)  i'm regularly propose to pass list syntax to the
special class which should define methods for building and analyzing
data in head/tail way:

class ListLike ce e | ce->e where
  -- Construction
  empty :: ce
  cons :: c -> ce -> ce

  -- Analyzing
  null :: ce -> Bool
  head :: ce -> e
  tail :: ce -> ce

and then the following definition:

trim (' ':xs) = trim xs
trim xs = xs

would imply the following type constraints:

trim :: (ListLike ce Char, Eq Char) =>  ce -> ce



-- 
Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com



More information about the Haskell-prime mailing list