loading
main.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
{-# LANGUAGE FlexibleContexts #-}
import Text.Show.Functions

addOne :: Num a => a -> a
addOne a = a + 1

addTwo :: Num a => a -> a
addTwo a = a + 2

main = do
  print $ ([      ]         <*> [ ]    :: [Int])
  print $ ([      ]         <*> [2]    :: [Int])
  print $ ([addOne]         <*> [ ]    :: [Int])
  print $ ([addOne]         <*> [2]    :: [Int])
  print $ ([addOne, addTwo] <*> [ ]    :: [Int])
  print $ ([addOne, addTwo] <*> [2]    :: [Int])
  print $ ([addOne, addTwo] <*> [2, 3] :: [Int])

  print $ (Nothing     <*> Nothing :: Maybe Int)
  print $ (Nothing     <*> Just 2  :: Maybe Int)
  print $ (Just addOne <*> Nothing :: Maybe Int)
  print $ (Just addOne <*> Just 2  :: Maybe Int)

  print $ (Left  addOne <*> Right 2 :: Either (Int -> Int) Int)
  print $ (Right addOne <*> Left  2 :: Either Int Int)
  print $ (Right addOne <*> Right 2 :: Either Int Int)
GHCi, version 8.6.5