/
Example.hs
51 lines (34 loc) · 932 Bytes
/
Example.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
module Example where
import Foreign.C.Types (CInt(..))
import Foreign.C.String
newtype Custom = Custom
{ getCustom :: Int
} deriving (Show, Eq)
toCustom = Custom
fromCustom = getCustom
foreign export ccall toCustom :: Int -> Custom
foreign export ccall fromCustom :: Custom -> Int
someConstant :: Int
someConstant = 63
hello :: IO ()
hello = putStrLn "Hello from Haskell!"
square :: CInt -> CInt
square i = i * i
multisin :: Int -> Double -> Double
multisin x y = (fromIntegral x) * (sin y)
pythasLen :: [Integer] -> Int
pythasLen = length
someComplicatedFunc :: [a] -> IO a
someComplicatedFunc = undefined
mapQuarter :: [Integer] -> [Double]
mapQuarter = map ((*0.25) . fromIntegral)
haskellList :: [Int]
haskellList = [63]
strings :: String -> String
strings = filter (/= 'a')
nested :: [[String]] -> [[String]]
nested = id
tuple :: (Int, String)
tuple = (1, "a")
hsnd :: (Int, Int) -> Int
hsnd (_,b) = b