Last active
August 29, 2015 14:21
-
-
Save Jonplussed/413b3655f8df23e5cafc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module DefArgs | |
( Vec4 (..) | |
, ToVec4 | |
, toVec4 | |
) where | |
data Vec4 = Vec4 Number Number Number Number | |
instance showVec4 :: Show Vec4 where | |
show (Vec4 x y z t) = | |
"(Vec4 " ++ | |
show x ++ " " ++ | |
show y ++ " " ++ | |
show z ++ " " ++ | |
show t ++ ")" | |
class ToVec4 a where | |
toVec4 :: a -> Vec4 | |
instance toVec4AllArgs :: ToVec4 Vec4 where | |
toVec4 = id | |
instance toVec4With3Args :: ToVec4 (Number -> Vec4) where | |
toVec4 f = f 1 | |
instance toVec4With2Args :: ToVec4 (Number -> Number -> Vec4) where | |
toVec4 f = f 0 1 | |
{- | |
toVec4 $ Vec4 3 2 1 5 | |
=> (Vec4 3 2 1 5) | |
toVec4 $ Vec4 3 2 | |
=> (Vec4 3 2 0 1) | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment