{-# LANGUAGE NoImplicitPrelude #-}
module Codec.QRCode
(
encode
, encodeAutomatic
, encodeText
, encodeBinary
, encodeKanji
, encodeAlphanumeric
, encodeNumeric
, module Codec.QRCode.Data.QRCodeOptions
, module Codec.QRCode.Data.ErrorLevel
, module Codec.QRCode.Data.Mask
, module Codec.QRCode.Data.TextEncoding
, module Codec.QRCode.Data.ToInput
, module Codec.QRCode.Data.QRImage
) where
import Codec.QRCode.Base
import Codec.QRCode.Code.Intermediate
import Codec.QRCode.Data.ErrorLevel
import Codec.QRCode.Data.Mask
import Codec.QRCode.Data.QRCodeOptions
import Codec.QRCode.Data.QRImage
import Codec.QRCode.Data.Result
import Codec.QRCode.Data.TextEncoding
import Codec.QRCode.Data.ToInput
import Codec.QRCode.Mode.Alphanumeric
import Codec.QRCode.Mode.Automatic
import Codec.QRCode.Mode.Byte
import Codec.QRCode.Mode.Kanji
import Codec.QRCode.Mode.Mixed
import Codec.QRCode.Mode.Numeric
encode :: ToText a => QRCodeOptions -> TextEncoding -> a -> Maybe QRImage
{-# INLINABLE encode #-}
encode :: QRCodeOptions -> TextEncoding -> a -> Maybe QRImage
encode QRCodeOptions
opt TextEncoding
te = Result QRImage -> Maybe QRImage
forall a. Result a -> Maybe a
getResult (Result QRImage -> Maybe QRImage)
-> (a -> Result QRImage) -> a -> Maybe QRImage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (QRIntermediate -> QRImage
fromIntermediate (QRIntermediate -> QRImage)
-> Result QRIntermediate -> Result QRImage
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) (Result QRIntermediate -> Result QRImage)
-> (a -> Result QRIntermediate) -> a -> Result QRImage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (QRCodeOptions -> QRSegment -> Result QRIntermediate
toIntermediate QRCodeOptions
opt (QRSegment -> Result QRIntermediate)
-> Result QRSegment -> Result QRIntermediate
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<) (Result QRSegment -> Result QRIntermediate)
-> (a -> Result QRSegment) -> a -> Result QRIntermediate
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TextEncoding -> a -> Result QRSegment
forall a. ToText a => TextEncoding -> a -> Result QRSegment
mixed TextEncoding
te
encodeAutomatic :: ToText a => QRCodeOptions -> TextEncoding -> a -> Maybe QRImage
{-# INLINABLE encodeAutomatic #-}
encodeAutomatic :: QRCodeOptions -> TextEncoding -> a -> Maybe QRImage
encodeAutomatic QRCodeOptions
opt TextEncoding
te = Result QRImage -> Maybe QRImage
forall a. Result a -> Maybe a
getResult (Result QRImage -> Maybe QRImage)
-> (a -> Result QRImage) -> a -> Maybe QRImage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (QRIntermediate -> QRImage
fromIntermediate (QRIntermediate -> QRImage)
-> Result QRIntermediate -> Result QRImage
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) (Result QRIntermediate -> Result QRImage)
-> (a -> Result QRIntermediate) -> a -> Result QRImage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (QRCodeOptions -> QRSegment -> Result QRIntermediate
toIntermediate QRCodeOptions
opt (QRSegment -> Result QRIntermediate)
-> Result QRSegment -> Result QRIntermediate
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<) (Result QRSegment -> Result QRIntermediate)
-> (a -> Result QRSegment) -> a -> Result QRIntermediate
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TextEncoding -> a -> Result QRSegment
forall a. ToText a => TextEncoding -> a -> Result QRSegment
automatic TextEncoding
te
encodeText :: ToText a => QRCodeOptions -> TextEncoding -> a -> Maybe QRImage
{-# INLINABLE encodeText #-}
encodeText :: QRCodeOptions -> TextEncoding -> a -> Maybe QRImage
encodeText QRCodeOptions
opt TextEncoding
te = Result QRImage -> Maybe QRImage
forall a. Result a -> Maybe a
getResult (Result QRImage -> Maybe QRImage)
-> (a -> Result QRImage) -> a -> Maybe QRImage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (QRIntermediate -> QRImage
fromIntermediate (QRIntermediate -> QRImage)
-> Result QRIntermediate -> Result QRImage
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) (Result QRIntermediate -> Result QRImage)
-> (a -> Result QRIntermediate) -> a -> Result QRImage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (QRCodeOptions -> QRSegment -> Result QRIntermediate
toIntermediate QRCodeOptions
opt (QRSegment -> Result QRIntermediate)
-> Result QRSegment -> Result QRIntermediate
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<) (Result QRSegment -> Result QRIntermediate)
-> (a -> Result QRSegment) -> a -> Result QRIntermediate
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TextEncoding -> a -> Result QRSegment
forall a. ToText a => TextEncoding -> a -> Result QRSegment
text TextEncoding
te
encodeBinary :: ToBinary a => QRCodeOptions -> a -> Maybe QRImage
{-# INLINABLE encodeBinary #-}
encodeBinary :: QRCodeOptions -> a -> Maybe QRImage
encodeBinary QRCodeOptions
opt = Result QRImage -> Maybe QRImage
forall a. Result a -> Maybe a
getResult (Result QRImage -> Maybe QRImage)
-> (a -> Result QRImage) -> a -> Maybe QRImage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (QRIntermediate -> QRImage
fromIntermediate (QRIntermediate -> QRImage)
-> Result QRIntermediate -> Result QRImage
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) (Result QRIntermediate -> Result QRImage)
-> (a -> Result QRIntermediate) -> a -> Result QRImage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QRCodeOptions -> QRSegment -> Result QRIntermediate
toIntermediate QRCodeOptions
opt (QRSegment -> Result QRIntermediate)
-> (a -> QRSegment) -> a -> Result QRIntermediate
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> QRSegment
forall a. ToBinary a => a -> QRSegment
binary
encodeKanji :: ToText a => QRCodeOptions -> a -> Maybe QRImage
{-# INLINABLE encodeKanji #-}
encodeKanji :: QRCodeOptions -> a -> Maybe QRImage
encodeKanji QRCodeOptions
opt = Result QRImage -> Maybe QRImage
forall a. Result a -> Maybe a
getResult (Result QRImage -> Maybe QRImage)
-> (a -> Result QRImage) -> a -> Maybe QRImage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (QRIntermediate -> QRImage
fromIntermediate (QRIntermediate -> QRImage)
-> Result QRIntermediate -> Result QRImage
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) (Result QRIntermediate -> Result QRImage)
-> (a -> Result QRIntermediate) -> a -> Result QRImage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (QRCodeOptions -> QRSegment -> Result QRIntermediate
toIntermediate QRCodeOptions
opt (QRSegment -> Result QRIntermediate)
-> Result QRSegment -> Result QRIntermediate
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<) (Result QRSegment -> Result QRIntermediate)
-> (a -> Result QRSegment) -> a -> Result QRIntermediate
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Result QRSegment
forall a. ToText a => a -> Result QRSegment
kanji
encodeAlphanumeric :: ToText a => QRCodeOptions -> a -> Maybe QRImage
{-# INLINABLE encodeAlphanumeric #-}
encodeAlphanumeric :: QRCodeOptions -> a -> Maybe QRImage
encodeAlphanumeric QRCodeOptions
opt = Result QRImage -> Maybe QRImage
forall a. Result a -> Maybe a
getResult (Result QRImage -> Maybe QRImage)
-> (a -> Result QRImage) -> a -> Maybe QRImage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (QRIntermediate -> QRImage
fromIntermediate (QRIntermediate -> QRImage)
-> Result QRIntermediate -> Result QRImage
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) (Result QRIntermediate -> Result QRImage)
-> (a -> Result QRIntermediate) -> a -> Result QRImage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (QRCodeOptions -> QRSegment -> Result QRIntermediate
toIntermediate QRCodeOptions
opt (QRSegment -> Result QRIntermediate)
-> Result QRSegment -> Result QRIntermediate
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<) (Result QRSegment -> Result QRIntermediate)
-> (a -> Result QRSegment) -> a -> Result QRIntermediate
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Result QRSegment
forall a. ToText a => a -> Result QRSegment
alphanumeric
encodeNumeric :: ToNumeric a => QRCodeOptions -> a -> Maybe QRImage
{-# INLINABLE encodeNumeric #-}
encodeNumeric :: QRCodeOptions -> a -> Maybe QRImage
encodeNumeric QRCodeOptions
opt = Result QRImage -> Maybe QRImage
forall a. Result a -> Maybe a
getResult (Result QRImage -> Maybe QRImage)
-> (a -> Result QRImage) -> a -> Maybe QRImage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (QRIntermediate -> QRImage
fromIntermediate (QRIntermediate -> QRImage)
-> Result QRIntermediate -> Result QRImage
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) (Result QRIntermediate -> Result QRImage)
-> (a -> Result QRIntermediate) -> a -> Result QRImage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (QRCodeOptions -> QRSegment -> Result QRIntermediate
toIntermediate QRCodeOptions
opt (QRSegment -> Result QRIntermediate)
-> Result QRSegment -> Result QRIntermediate
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<) (Result QRSegment -> Result QRIntermediate)
-> (a -> Result QRSegment) -> a -> Result QRIntermediate
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Result QRSegment
forall a. ToNumeric a => a -> Result QRSegment
numeric