mirror of
https://github.com/Noratrieb/idris-learning.git
synced 2026-01-15 05:25:06 +01:00
initial commit
This commit is contained in:
commit
80aa1a2be7
8 changed files with 142 additions and 0 deletions
26
Hello.idr
Normal file
26
Hello.idr
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
module Main
|
||||
main : IO ()
|
||||
main = putStrLn "hello world"
|
||||
|
||||
StringOrInt : Bool -> Type
|
||||
StringOrInt x = case x of
|
||||
True => Int
|
||||
False => String
|
||||
|
||||
|
||||
getStringOrInt : (x : Bool) -> StringOrInt x
|
||||
getStringOrInt x = case x of
|
||||
True => 94
|
||||
False => "Ninety four"
|
||||
|
||||
TypeChooser : String -> Type
|
||||
TypeChooser x = case x of
|
||||
"Int" => Int
|
||||
"Bool" => Bool
|
||||
"String" => String
|
||||
"Char" => Char
|
||||
|
||||
valToString : (typeChoice : Bool) -> StringOrInt typeChoice -> String
|
||||
valToString typeChoice val = case typeChoice of
|
||||
True => cast val -- True means that our argument type is Int, so cast
|
||||
False => val -- False means that our agumet type is String, so no need to cast
|
||||
Loading…
Add table
Add a link
Reference in a new issue