{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
module THREE.Constants.Materials
(
Side (..)
, BlendingMode (..)
, DepthMode (..)
, TextureCombineOperations (..)
, StencilFunctions (..)
, StencilOperations (..)
, NormalMapType (..)
, GlslVersion (..)
, Linecap (..)
, Linejoin (..)
) where
import Miso
data Side
= FrontSide
| BackSide
| DoubleSide
instance ToJSVal Side where
toJSVal :: Side -> IO JSVal
toJSVal = Int -> IO JSVal
forall a. ToJSVal a => a -> IO JSVal
toJSVal (Int -> IO JSVal) -> (Side -> Int) -> Side -> IO JSVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Side -> Int
go
where
go :: Side -> Int
go :: Side -> Int
go = \case
Side
FrontSide -> Int
0
Side
BackSide -> Int
1
Side
DoubleSide -> Int
2
instance FromJSVal Side where
fromJSVal :: JSVal -> IO (Maybe Side)
fromJSVal = (Maybe Int -> Maybe Side) -> IO (Maybe Int) -> IO (Maybe Side)
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Maybe Int -> (Int -> Maybe Side) -> Maybe Side
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Int -> Maybe Side
go) (IO (Maybe Int) -> IO (Maybe Side))
-> (JSVal -> IO (Maybe Int)) -> JSVal -> IO (Maybe Side)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSVal -> IO (Maybe Int)
forall a. FromJSVal a => JSVal -> IO (Maybe a)
fromJSVal
where
go :: Int -> Maybe Side
go :: Int -> Maybe Side
go = \case
Int
0 -> Side -> Maybe Side
forall a. a -> Maybe a
Just Side
FrontSide
Int
1 -> Side -> Maybe Side
forall a. a -> Maybe a
Just Side
BackSide
Int
2 -> Side -> Maybe Side
forall a. a -> Maybe a
Just Side
DoubleSide
Int
_ -> Maybe Side
forall a. Maybe a
Nothing
data BlendingMode
= NoBlending
| NormalBlending
| AdditiveBlending
| SubtractiveBlending
| MultiplyBlending
| CustomBlending
instance ToJSVal BlendingMode where
toJSVal :: BlendingMode -> IO JSVal
toJSVal = Int -> IO JSVal
forall a. ToJSVal a => a -> IO JSVal
toJSVal (Int -> IO JSVal)
-> (BlendingMode -> Int) -> BlendingMode -> IO JSVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BlendingMode -> Int
go
where
go :: BlendingMode -> Int
go :: BlendingMode -> Int
go = \case
BlendingMode
NoBlending -> Int
0
BlendingMode
NormalBlending -> Int
1
BlendingMode
AdditiveBlending -> Int
2
BlendingMode
SubtractiveBlending -> Int
3
BlendingMode
MultiplyBlending -> Int
4
BlendingMode
CustomBlending -> Int
5
instance FromJSVal BlendingMode where
fromJSVal :: JSVal -> IO (Maybe BlendingMode)
fromJSVal = (Maybe Int -> Maybe BlendingMode)
-> IO (Maybe Int) -> IO (Maybe BlendingMode)
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Maybe Int -> (Int -> Maybe BlendingMode) -> Maybe BlendingMode
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Int -> Maybe BlendingMode
go) (IO (Maybe Int) -> IO (Maybe BlendingMode))
-> (JSVal -> IO (Maybe Int)) -> JSVal -> IO (Maybe BlendingMode)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSVal -> IO (Maybe Int)
forall a. FromJSVal a => JSVal -> IO (Maybe a)
fromJSVal
where
go :: Int -> Maybe BlendingMode
go :: Int -> Maybe BlendingMode
go = \case
Int
0 -> BlendingMode -> Maybe BlendingMode
forall a. a -> Maybe a
Just BlendingMode
NoBlending
Int
1 -> BlendingMode -> Maybe BlendingMode
forall a. a -> Maybe a
Just BlendingMode
NormalBlending
Int
2 -> BlendingMode -> Maybe BlendingMode
forall a. a -> Maybe a
Just BlendingMode
AdditiveBlending
Int
3 -> BlendingMode -> Maybe BlendingMode
forall a. a -> Maybe a
Just BlendingMode
SubtractiveBlending
Int
4 -> BlendingMode -> Maybe BlendingMode
forall a. a -> Maybe a
Just BlendingMode
MultiplyBlending
Int
5 -> BlendingMode -> Maybe BlendingMode
forall a. a -> Maybe a
Just BlendingMode
CustomBlending
Int
_ -> Maybe BlendingMode
forall a. Maybe a
Nothing
data DepthMode
= NeverDepth
| AlwaysDepth
| EqualDepth
| LessDepth
| LessEqualDepth
| GreaterEqualDepth
| GreaterDepth
| NotEqualDepth
instance ToJSVal DepthMode where
toJSVal :: DepthMode -> IO JSVal
toJSVal = Int -> IO JSVal
forall a. ToJSVal a => a -> IO JSVal
toJSVal (Int -> IO JSVal) -> (DepthMode -> Int) -> DepthMode -> IO JSVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DepthMode -> Int
go
where
go :: DepthMode -> Int
go :: DepthMode -> Int
go = \case
DepthMode
NeverDepth -> Int
0
DepthMode
AlwaysDepth -> Int
1
DepthMode
EqualDepth -> Int
2
DepthMode
LessDepth -> Int
3
DepthMode
LessEqualDepth -> Int
4
DepthMode
GreaterEqualDepth -> Int
5
DepthMode
GreaterDepth -> Int
6
DepthMode
NotEqualDepth -> Int
7
instance FromJSVal DepthMode where
fromJSVal :: JSVal -> IO (Maybe DepthMode)
fromJSVal = (Maybe Int -> Maybe DepthMode)
-> IO (Maybe Int) -> IO (Maybe DepthMode)
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Maybe Int -> (Int -> Maybe DepthMode) -> Maybe DepthMode
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Int -> Maybe DepthMode
go) (IO (Maybe Int) -> IO (Maybe DepthMode))
-> (JSVal -> IO (Maybe Int)) -> JSVal -> IO (Maybe DepthMode)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSVal -> IO (Maybe Int)
forall a. FromJSVal a => JSVal -> IO (Maybe a)
fromJSVal
where
go :: Int -> Maybe DepthMode
go :: Int -> Maybe DepthMode
go = \case
Int
0 -> DepthMode -> Maybe DepthMode
forall a. a -> Maybe a
Just DepthMode
NeverDepth
Int
1 -> DepthMode -> Maybe DepthMode
forall a. a -> Maybe a
Just DepthMode
AlwaysDepth
Int
2 -> DepthMode -> Maybe DepthMode
forall a. a -> Maybe a
Just DepthMode
EqualDepth
Int
3 -> DepthMode -> Maybe DepthMode
forall a. a -> Maybe a
Just DepthMode
LessDepth
Int
4 -> DepthMode -> Maybe DepthMode
forall a. a -> Maybe a
Just DepthMode
LessEqualDepth
Int
5 -> DepthMode -> Maybe DepthMode
forall a. a -> Maybe a
Just DepthMode
GreaterEqualDepth
Int
6 -> DepthMode -> Maybe DepthMode
forall a. a -> Maybe a
Just DepthMode
GreaterDepth
Int
7 -> DepthMode -> Maybe DepthMode
forall a. a -> Maybe a
Just DepthMode
NotEqualDepth
Int
_ -> Maybe DepthMode
forall a. Maybe a
Nothing
data TextureCombineOperations
= MultiplyOperation
| MixOperation
| AddOperation
instance ToJSVal TextureCombineOperations where
toJSVal :: TextureCombineOperations -> IO JSVal
toJSVal = Int -> IO JSVal
forall a. ToJSVal a => a -> IO JSVal
toJSVal (Int -> IO JSVal)
-> (TextureCombineOperations -> Int)
-> TextureCombineOperations
-> IO JSVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TextureCombineOperations -> Int
go
where
go :: TextureCombineOperations -> Int
go :: TextureCombineOperations -> Int
go = \case
TextureCombineOperations
MultiplyOperation -> Int
0
TextureCombineOperations
MixOperation -> Int
1
TextureCombineOperations
AddOperation -> Int
2
instance FromJSVal TextureCombineOperations where
fromJSVal :: JSVal -> IO (Maybe TextureCombineOperations)
fromJSVal = (Maybe Int -> Maybe TextureCombineOperations)
-> IO (Maybe Int) -> IO (Maybe TextureCombineOperations)
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Maybe Int
-> (Int -> Maybe TextureCombineOperations)
-> Maybe TextureCombineOperations
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Int -> Maybe TextureCombineOperations
go) (IO (Maybe Int) -> IO (Maybe TextureCombineOperations))
-> (JSVal -> IO (Maybe Int))
-> JSVal
-> IO (Maybe TextureCombineOperations)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSVal -> IO (Maybe Int)
forall a. FromJSVal a => JSVal -> IO (Maybe a)
fromJSVal
where
go :: Int -> Maybe TextureCombineOperations
go :: Int -> Maybe TextureCombineOperations
go = \case
Int
0 -> TextureCombineOperations -> Maybe TextureCombineOperations
forall a. a -> Maybe a
Just TextureCombineOperations
MultiplyOperation
Int
1 -> TextureCombineOperations -> Maybe TextureCombineOperations
forall a. a -> Maybe a
Just TextureCombineOperations
MixOperation
Int
2 -> TextureCombineOperations -> Maybe TextureCombineOperations
forall a. a -> Maybe a
Just TextureCombineOperations
AddOperation
Int
_ -> Maybe TextureCombineOperations
forall a. Maybe a
Nothing
data StencilFunctions
= NeverStencilFunc
| LessStencilFunc
| EqualStencilFunc
| LessEqualStencilFunc
| GreaterStencilFunc
| NotEqualStencilFunc
| GreaterEqualStencilFunc
| AlwaysStencilFunc
instance ToJSVal StencilFunctions where
toJSVal :: StencilFunctions -> IO JSVal
toJSVal = Int -> IO JSVal
forall a. ToJSVal a => a -> IO JSVal
toJSVal (Int -> IO JSVal)
-> (StencilFunctions -> Int) -> StencilFunctions -> IO JSVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StencilFunctions -> Int
go
where
go :: StencilFunctions -> Int
go :: StencilFunctions -> Int
go = \case
StencilFunctions
NeverStencilFunc -> Int
512
StencilFunctions
LessStencilFunc -> Int
513
StencilFunctions
EqualStencilFunc -> Int
514
StencilFunctions
LessEqualStencilFunc -> Int
515
StencilFunctions
GreaterStencilFunc -> Int
516
StencilFunctions
NotEqualStencilFunc -> Int
517
StencilFunctions
GreaterEqualStencilFunc -> Int
518
StencilFunctions
AlwaysStencilFunc -> Int
519
instance FromJSVal StencilFunctions where
fromJSVal :: JSVal -> IO (Maybe StencilFunctions)
fromJSVal = (Maybe Int -> Maybe StencilFunctions)
-> IO (Maybe Int) -> IO (Maybe StencilFunctions)
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Maybe Int
-> (Int -> Maybe StencilFunctions) -> Maybe StencilFunctions
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Int -> Maybe StencilFunctions
go) (IO (Maybe Int) -> IO (Maybe StencilFunctions))
-> (JSVal -> IO (Maybe Int))
-> JSVal
-> IO (Maybe StencilFunctions)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSVal -> IO (Maybe Int)
forall a. FromJSVal a => JSVal -> IO (Maybe a)
fromJSVal
where
go :: Int -> Maybe StencilFunctions
go :: Int -> Maybe StencilFunctions
go = \case
Int
512 -> StencilFunctions -> Maybe StencilFunctions
forall a. a -> Maybe a
Just StencilFunctions
NeverStencilFunc
Int
513 -> StencilFunctions -> Maybe StencilFunctions
forall a. a -> Maybe a
Just StencilFunctions
LessStencilFunc
Int
514 -> StencilFunctions -> Maybe StencilFunctions
forall a. a -> Maybe a
Just StencilFunctions
EqualStencilFunc
Int
515 -> StencilFunctions -> Maybe StencilFunctions
forall a. a -> Maybe a
Just StencilFunctions
LessEqualStencilFunc
Int
516 -> StencilFunctions -> Maybe StencilFunctions
forall a. a -> Maybe a
Just StencilFunctions
GreaterStencilFunc
Int
517 -> StencilFunctions -> Maybe StencilFunctions
forall a. a -> Maybe a
Just StencilFunctions
NotEqualStencilFunc
Int
518 -> StencilFunctions -> Maybe StencilFunctions
forall a. a -> Maybe a
Just StencilFunctions
GreaterEqualStencilFunc
Int
519 -> StencilFunctions -> Maybe StencilFunctions
forall a. a -> Maybe a
Just StencilFunctions
AlwaysStencilFunc
Int
_ -> Maybe StencilFunctions
forall a. Maybe a
Nothing
data StencilOperations
= ZeroStencilOp
| KeepStencilOp
| ReplaceStencilOp
| IncrementStencilOp
| DecrementStencilOp
| IncrementWrapStencilOp
| DecrementWrapStencilOp
| InvertStencilOp
instance ToJSVal StencilOperations where
toJSVal :: StencilOperations -> IO JSVal
toJSVal = Int -> IO JSVal
forall a. ToJSVal a => a -> IO JSVal
toJSVal (Int -> IO JSVal)
-> (StencilOperations -> Int) -> StencilOperations -> IO JSVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StencilOperations -> Int
go
where
go :: StencilOperations -> Int
go :: StencilOperations -> Int
go = \case
StencilOperations
ZeroStencilOp -> Int
0
StencilOperations
KeepStencilOp -> Int
7680
StencilOperations
ReplaceStencilOp -> Int
7681
StencilOperations
IncrementStencilOp -> Int
7682
StencilOperations
DecrementStencilOp -> Int
7683
StencilOperations
IncrementWrapStencilOp -> Int
34055
StencilOperations
DecrementWrapStencilOp -> Int
34056
StencilOperations
InvertStencilOp -> Int
5386
instance FromJSVal StencilOperations where
fromJSVal :: JSVal -> IO (Maybe StencilOperations)
fromJSVal = (Maybe Int -> Maybe StencilOperations)
-> IO (Maybe Int) -> IO (Maybe StencilOperations)
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Maybe Int
-> (Int -> Maybe StencilOperations) -> Maybe StencilOperations
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Int -> Maybe StencilOperations
go) (IO (Maybe Int) -> IO (Maybe StencilOperations))
-> (JSVal -> IO (Maybe Int))
-> JSVal
-> IO (Maybe StencilOperations)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSVal -> IO (Maybe Int)
forall a. FromJSVal a => JSVal -> IO (Maybe a)
fromJSVal
where
go :: Int -> Maybe StencilOperations
go :: Int -> Maybe StencilOperations
go = \case
Int
0 -> StencilOperations -> Maybe StencilOperations
forall a. a -> Maybe a
Just StencilOperations
ZeroStencilOp
Int
7680 -> StencilOperations -> Maybe StencilOperations
forall a. a -> Maybe a
Just StencilOperations
KeepStencilOp
Int
7681 -> StencilOperations -> Maybe StencilOperations
forall a. a -> Maybe a
Just StencilOperations
ReplaceStencilOp
Int
7682 -> StencilOperations -> Maybe StencilOperations
forall a. a -> Maybe a
Just StencilOperations
IncrementStencilOp
Int
7683 -> StencilOperations -> Maybe StencilOperations
forall a. a -> Maybe a
Just StencilOperations
DecrementStencilOp
Int
34055 -> StencilOperations -> Maybe StencilOperations
forall a. a -> Maybe a
Just StencilOperations
IncrementWrapStencilOp
Int
34056 -> StencilOperations -> Maybe StencilOperations
forall a. a -> Maybe a
Just StencilOperations
DecrementWrapStencilOp
Int
5386 -> StencilOperations -> Maybe StencilOperations
forall a. a -> Maybe a
Just StencilOperations
InvertStencilOp
Int
_ -> Maybe StencilOperations
forall a. Maybe a
Nothing
data NormalMapType
= TangentSpaceNormalMap
| ObjectSpaceNormalMap
instance ToJSVal NormalMapType where
toJSVal :: NormalMapType -> IO JSVal
toJSVal = Int -> IO JSVal
forall a. ToJSVal a => a -> IO JSVal
toJSVal (Int -> IO JSVal)
-> (NormalMapType -> Int) -> NormalMapType -> IO JSVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NormalMapType -> Int
go
where
go :: NormalMapType -> Int
go :: NormalMapType -> Int
go = \case
NormalMapType
TangentSpaceNormalMap -> Int
0
NormalMapType
ObjectSpaceNormalMap -> Int
1
instance FromJSVal NormalMapType where
fromJSVal :: JSVal -> IO (Maybe NormalMapType)
fromJSVal = (Maybe Int -> Maybe NormalMapType)
-> IO (Maybe Int) -> IO (Maybe NormalMapType)
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Maybe Int -> (Int -> Maybe NormalMapType) -> Maybe NormalMapType
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Int -> Maybe NormalMapType
go) (IO (Maybe Int) -> IO (Maybe NormalMapType))
-> (JSVal -> IO (Maybe Int)) -> JSVal -> IO (Maybe NormalMapType)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSVal -> IO (Maybe Int)
forall a. FromJSVal a => JSVal -> IO (Maybe a)
fromJSVal
where
go :: Int -> Maybe NormalMapType
go :: Int -> Maybe NormalMapType
go = \case
Int
0 -> NormalMapType -> Maybe NormalMapType
forall a. a -> Maybe a
Just NormalMapType
TangentSpaceNormalMap
Int
1 -> NormalMapType -> Maybe NormalMapType
forall a. a -> Maybe a
Just NormalMapType
ObjectSpaceNormalMap
Int
_ -> Maybe NormalMapType
forall a. Maybe a
Nothing
data GlslVersion
= GLSL1
| GLSL3
instance ToJSVal GlslVersion where
toJSVal :: GlslVersion -> IO JSVal
toJSVal = MisoString -> IO JSVal
forall a. ToJSVal a => a -> IO JSVal
toJSVal (MisoString -> IO JSVal)
-> (GlslVersion -> MisoString) -> GlslVersion -> IO JSVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GlslVersion -> MisoString
go
where
go :: GlslVersion -> MisoString
go :: GlslVersion -> MisoString
go = \case
GlslVersion
GLSL1 -> MisoString
"100"
GlslVersion
GLSL3 -> MisoString
"300 es"
instance FromJSVal GlslVersion where
fromJSVal :: JSVal -> IO (Maybe GlslVersion)
fromJSVal = (Maybe MisoString -> Maybe GlslVersion)
-> IO (Maybe MisoString) -> IO (Maybe GlslVersion)
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Maybe MisoString
-> (MisoString -> Maybe GlslVersion) -> Maybe GlslVersion
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= MisoString -> Maybe GlslVersion
go) (IO (Maybe MisoString) -> IO (Maybe GlslVersion))
-> (JSVal -> IO (Maybe MisoString))
-> JSVal
-> IO (Maybe GlslVersion)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSVal -> IO (Maybe MisoString)
forall a. FromJSVal a => JSVal -> IO (Maybe a)
fromJSVal
where
go :: MisoString -> Maybe GlslVersion
go :: MisoString -> Maybe GlslVersion
go = \case
MisoString
"100" -> GlslVersion -> Maybe GlslVersion
forall a. a -> Maybe a
Just GlslVersion
GLSL1
MisoString
"300 es" -> GlslVersion -> Maybe GlslVersion
forall a. a -> Maybe a
Just GlslVersion
GLSL3
MisoString
_ -> Maybe GlslVersion
forall a. Maybe a
Nothing
data Linecap
= LinecapButt
| LinecapRound
| LinecapSquare
instance ToJSVal Linecap where
toJSVal :: Linecap -> IO JSVal
toJSVal = MisoString -> IO JSVal
forall a. ToJSVal a => a -> IO JSVal
toJSVal (MisoString -> IO JSVal)
-> (Linecap -> MisoString) -> Linecap -> IO JSVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Linecap -> MisoString
go
where
go :: Linecap -> MisoString
go :: Linecap -> MisoString
go = \case
Linecap
LinecapButt -> MisoString
"butt"
Linecap
LinecapRound -> MisoString
"round"
Linecap
LinecapSquare -> MisoString
"square"
instance FromJSVal Linecap where
fromJSVal :: JSVal -> IO (Maybe Linecap)
fromJSVal = (Maybe MisoString -> Maybe Linecap)
-> IO (Maybe MisoString) -> IO (Maybe Linecap)
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Maybe MisoString -> (MisoString -> Maybe Linecap) -> Maybe Linecap
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= MisoString -> Maybe Linecap
go) (IO (Maybe MisoString) -> IO (Maybe Linecap))
-> (JSVal -> IO (Maybe MisoString)) -> JSVal -> IO (Maybe Linecap)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSVal -> IO (Maybe MisoString)
forall a. FromJSVal a => JSVal -> IO (Maybe a)
fromJSVal
where
go :: MisoString -> Maybe Linecap
go :: MisoString -> Maybe Linecap
go = \case
MisoString
"butt" -> Linecap -> Maybe Linecap
forall a. a -> Maybe a
Just Linecap
LinecapButt
MisoString
"round" -> Linecap -> Maybe Linecap
forall a. a -> Maybe a
Just Linecap
LinecapRound
MisoString
"square" -> Linecap -> Maybe Linecap
forall a. a -> Maybe a
Just Linecap
LinecapSquare
MisoString
_ -> Maybe Linecap
forall a. Maybe a
Nothing
data Linejoin
= LinejoinBevel
| LinejoinMiter
| LinejoinRound
instance ToJSVal Linejoin where
toJSVal :: Linejoin -> IO JSVal
toJSVal = MisoString -> IO JSVal
forall a. ToJSVal a => a -> IO JSVal
toJSVal (MisoString -> IO JSVal)
-> (Linejoin -> MisoString) -> Linejoin -> IO JSVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Linejoin -> MisoString
go
where
go :: Linejoin -> MisoString
go :: Linejoin -> MisoString
go = \case
Linejoin
LinejoinBevel -> MisoString
"bevel"
Linejoin
LinejoinMiter -> MisoString
"miter"
Linejoin
LinejoinRound -> MisoString
"round"
instance FromJSVal Linejoin where
fromJSVal :: JSVal -> IO (Maybe Linejoin)
fromJSVal = (Maybe MisoString -> Maybe Linejoin)
-> IO (Maybe MisoString) -> IO (Maybe Linejoin)
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Maybe MisoString
-> (MisoString -> Maybe Linejoin) -> Maybe Linejoin
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= MisoString -> Maybe Linejoin
go) (IO (Maybe MisoString) -> IO (Maybe Linejoin))
-> (JSVal -> IO (Maybe MisoString)) -> JSVal -> IO (Maybe Linejoin)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSVal -> IO (Maybe MisoString)
forall a. FromJSVal a => JSVal -> IO (Maybe a)
fromJSVal
where
go :: MisoString -> Maybe Linejoin
go :: MisoString -> Maybe Linejoin
go = \case
MisoString
"bevel" -> Linejoin -> Maybe Linejoin
forall a. a -> Maybe a
Just Linejoin
LinejoinBevel
MisoString
"miter" -> Linejoin -> Maybe Linejoin
forall a. a -> Maybe a
Just Linejoin
LinejoinMiter
MisoString
"round" -> Linejoin -> Maybe Linejoin
forall a. a -> Maybe a
Just Linejoin
LinejoinRound
MisoString
_ -> Maybe Linejoin
forall a. Maybe a
Nothing