{-# LANGUAGE NoImplicitPrelude #-}
module Codec.QRCode.Mode.Automatic
( automatic
) where
import Codec.QRCode.Base
import Codec.QRCode.Data.QRSegment.Internal
import Codec.QRCode.Data.Result
import Codec.QRCode.Data.TextEncoding
import Codec.QRCode.Data.ToInput
import Codec.QRCode.Mode.Alphanumeric
import Codec.QRCode.Mode.Byte
import Codec.QRCode.Mode.Kanji
import Codec.QRCode.Mode.Numeric
automatic :: ToText a => TextEncoding -> a -> Result QRSegment
automatic te s = numeric s' <|> alphanumeric s' <|> kanji s' <|> text te s
where
s' :: [Char]
s' = toString s