LoginSignup
1
1

More than 5 years have passed since last update.

型合わせただけのレベルだけども。

% runghc
module Main where
import Text.ParserCombinators.ReadP

degit :: ReadP Char
degit = foldl (+++) (char '0') (map char "123456789")

main :: IO ()
main = do
  let parser = do seisu <- many degit
                  char '.'
                  syosu <- many degit
                  eof
                  return $ seisu ++ '.' : syosu
  let parsed = readP_to_S parser "123.456"
  print parsed

【実行結果】
[("123.456","")]
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1