Idris language preview
1. Module and a total function
module header, a type signature, and a case expression
horizon-dark
module Main
total
double : Int -> Int
double n = n + n
main : IO ()
main = do
let greeting = "Hello, " ++ "world"
case double 21 of
42 => putStrLn greeting
_ => putStrLn "nope" atom-one-dark
module Main
total
double : Int -> Int
double n = n + n
main : IO ()
main = do
let greeting = "Hello, " ++ "world"
case double 21 of
42 => putStrLn greeting
_ => putStrLn "nope" github-dark
module Main
total
double : Int -> Int
double n = n + n
main : IO ()
main = do
let greeting = "Hello, " ++ "world"
case double 21 of
42 => putStrLn greeting
_ => putStrLn "nope" dracula
module Main
total
double : Int -> Int
double n = n + n
main : IO ()
main = do
let greeting = "Hello, " ++ "world"
case double 21 of
42 => putStrLn greeting
_ => putStrLn "nope" nord
module Main
total
double : Int -> Int
double n = n + n
main : IO ()
main = do
let greeting = "Hello, " ++ "world"
case double 21 of
42 => putStrLn greeting
_ => putStrLn "nope" github
module Main
total
double : Int -> Int
double n = n + n
main : IO ()
main = do
let greeting = "Hello, " ++ "world"
case double 21 of
42 => putStrLn greeting
_ => putStrLn "nope" 2. Records and interfaces
a record type, an interface, and an implementation
horizon-dark
record Point where
constructor MkPoint
x, y : Int
interface Describable a where
describe : a -> String
implementation Describable Point where
describe (MkPoint x y) = "(" ++ show x ++ ", " ++ show y ++ ")" atom-one-dark
record Point where
constructor MkPoint
x, y : Int
interface Describable a where
describe : a -> String
implementation Describable Point where
describe (MkPoint x y) = "(" ++ show x ++ ", " ++ show y ++ ")" github-dark
record Point where
constructor MkPoint
x, y : Int
interface Describable a where
describe : a -> String
implementation Describable Point where
describe (MkPoint x y) = "(" ++ show x ++ ", " ++ show y ++ ")" dracula
record Point where
constructor MkPoint
x, y : Int
interface Describable a where
describe : a -> String
implementation Describable Point where
describe (MkPoint x y) = "(" ++ show x ++ ", " ++ show y ++ ")" nord
record Point where
constructor MkPoint
x, y : Int
interface Describable a where
describe : a -> String
implementation Describable Point where
describe (MkPoint x y) = "(" ++ show x ++ ", " ++ show y ++ ")" github
record Point where
constructor MkPoint
x, y : Int
interface Describable a where
describe : a -> String
implementation Describable Point where
describe (MkPoint x y) = "(" ++ show x ++ ", " ++ show y ++ ")" 3. Nested comments
a doc comment wrapping an example that has its own comment
horizon-dark
{- computes the double of a number
{- example: double 21 == 42 -}
-}
total
double : Int -> Int
double n = n + n atom-one-dark
{- computes the double of a number
{- example: double 21 == 42 -}
-}
total
double : Int -> Int
double n = n + n github-dark
{- computes the double of a number
{- example: double 21 == 42 -}
-}
total
double : Int -> Int
double n = n + n dracula
{- computes the double of a number
{- example: double 21 == 42 -}
-}
total
double : Int -> Int
double n = n + n nord
{- computes the double of a number
{- example: double 21 == 42 -}
-}
total
double : Int -> Int
double n = n + n github
{- computes the double of a number
{- example: double 21 == 42 -}
-}
total
double : Int -> Int
double n = n + n