ddellacosta has joined #nix-lang
ddellacosta has quit [Ping timeout: 245 seconds]
ddellacosta has joined #nix-lang
ddellacosta has quit [Ping timeout: 268 seconds]
__monty__ has joined #nix-lang
__monty__ has quit [Quit: leaving]
noonien has joined #nix-lang
ddellacosta has joined #nix-lang
ddellacosta has quit [Ping timeout: 250 seconds]
ddellacosta has joined #nix-lang
ddellacosta has quit [Ping timeout: 240 seconds]
ddellacosta has joined #nix-lang
__monty__ has joined #nix-lang
<
infinisil>
> let __pathExists = x: true; in import /foo/bar
<
{^_^}>
access to path '/foo/bar' is forbidden in restricted mode
<
infinisil>
> let __pathExists = x: true; in import <nixpkgs/foo>
<
{^_^}>
file 'nixpkgs/foo' was not found in the Nix search path (add it using $NIX_PATH or -I), at (string):230:39
<
infinisil>
> let __pathExists = x: true; in import <nixpkgs>
<
infinisil>
> <nixpkgs>
<
{^_^}>
/var/lib/nixbot/nixpkgs/master/repo
<
infinisil>
> let __pathExists = x: true; in import /var/lib/nixbot/nixpkgs/master/repo/test
<
{^_^}>
getting status of '/var/lib/nixbot/nixpkgs/master/repo/test': No such file or directory
<
infinisil>
> import /var/lib/nixbot/nixpkgs/master/repo/test
<
{^_^}>
getting status of '/var/lib/nixbot/nixpkgs/master/repo/test': No such file or directory
<
infinisil>
> __pathExists "${pkgs.hello}"
<
{^_^}>
string '/nix/store/5blzqmi4735d90rdrw26byjnn2bdzm4b-hello-2.10' cannot refer to other paths, at (string):230:1
<
infinisil>
> let __pathExists = x: true; in __pathExists "${pkgs.hello}"
<
infinisil>
> builtinTypes = [ "int" "bool" "string" "path" "null" "set" "list" "lambda" "float" ]
<
{^_^}>
builtinTypes defined
<
infinisil>
> toString 10
<
infinisil>
> toString true
<
infinisil>
> toString /foo/bar
<
infinisil>
> toString null
<
infinisil>
> toString { x = 10; }
<
{^_^}>
cannot coerce a set to a string, at (string):231:1
<
infinisil>
> convertToString = val: { null = "null"; set = concatMapStringsSep " " (name: "${name} = ${convertToString val.${name}};") (lib.attrNames val); }.${builtins.typeOf val}
<
{^_^}>
error: undefined variable 'concatMapStringsSep' at (string):51:48
<
infinisil>
> convertToString = val: { null = "null"; set = lib.concatMapStringsSep " " (name: "${name} = ${convertToString val.${name}};") (lib.attrNames val); }.${builtins.typeOf val}
<
{^_^}>
convertToString defined
<
infinisil>
> convertToString { x = 10; }
<
{^_^}>
attribute 'int' missing, at (string):51:25
<
infinisil>
> convertToString = val: { null = "null"; set = lib.concatMapStringsSep " " (name: "${name} = ${convertToString val.${name}};") (lib.attrNames val); }.${builtins.typeOf val} or toString val
<
{^_^}>
convertToString defined
<
infinisil>
> convertToString { x = 10; }
<
{^_^}>
attempt to call something which is not a function but a string, at (string):51:25
<
infinisil>
> convertToString = val: { null = "null"; set = lib.concatMapStringsSep " " (name: "${name} = ${convertToString val.${name}};") (lib.attrNames val); }.${builtins.typeOf val} or (toString val)
<
{^_^}>
convertToString defined
<
infinisil>
> convertToString { x = 10; }
<
infinisil>
> convertToString = val: { null = "null"; set = "{ " + lib.concatMapStringsSep " " (name: "${name} = ${convertToString val.${name}};") (lib.attrNames val) + " }"; }.${builtins.typeOf val} or (toString val)
<
{^_^}>
convertToString defined
<
infinisil>
> convertToString { x = 10; }
<
{^_^}>
"{ x = 10; }"
<
infinisil>
> convertToString { x = 10; hello = { x = 10; }; }
<
{^_^}>
"{ hello = { x = 10; }; x = 10; }"
<
infinisil>
> convertToString = val: { null = "null"; set = "{ " + lib.concatMapStringsSep " " (name: "${name} = ${convertToString val.${name}};") (lib.attrNames val) + " }"; list = "[ " + lib.concatMapStringsSep " " convertToString val + " ]"; }.${builtins.typeOf val} or (toString val)
<
{^_^}>
convertToString defined
<
infinisil>
> convertToString { x = 10; hello = [ "test" 10 ]; }
<
{^_^}>
"{ hello = [ test 10 ]; x = 10; }"
<
infinisil>
> convertToString = val: { null = "null"; set = "{ " + lib.concatMapStringsSep " " (name: "${name} = ${convertToString val.${name}};") (lib.attrNames val) + " }"; list = "[ " + lib.concatMapStringsSep " " convertToString val + " ]"; lambda = "<LAMBDA>"; }.${builtins.typeOf val} or (toString val)
<
{^_^}>
convertToString defined
<
infinisil>
> convertToString { x = 10; hello = [ "test" 10 ]; test = x: x; }
<
{^_^}>
"{ hello = [ test 10 ]; test = <LAMBDA>; x = 10; }"
<
infinisil>
> convertToInt = val: { int = val; bool = if val then 1 else 0; string = lib.toInt val; path = lib.toInt val; null = 0; set = lib.length (lib.attrNames val); list = lib.length val; lambda = throw "Can't convert lambda to int"; float = throw "Can't convert float to int, yet"; }.${builtins.typeOf val}
<
{^_^}>
convertToInt defined
<
infinisil>
> convertToInt "10"
<
infinisil>
> convertToInt "1.0"
<
{^_^}>
Could not convert 1.0 to int.
<
infinisil>
> convertToInt [ 10 20 30 ]
<
infinisil>
> convertToInt true
<
infinisil>
> builtinTypes
<
{^_^}>
[ "int" "bool" "string" "path" "null" "set" "list" "lambda" "float" ]
<
infinisil>
> convertToBool = val: { int = val != 0; bool = val; string = lib.stringLength val != 0; path = builtins.pathExists val; null = false; set = val != {}; list = val != []; lambda = throw "Can't convert lambda to bool"; float = val != 0.0; }.${builtins.typeOf val}
<
{^_^}>
convertToBool defined
<
infinisil>
> convertToBool 10
<
infinisil>
> convertToBool true
<
infinisil>
> convertToBool "test"
<
infinisil>
> convertToBool ""
<
infinisil>
> convertToBool (<nixpkgs> + "/foo")
<
infinisil>
> convertToBool (<nixpkgs> + "/pkgs")
<
infinisil>
> convertToList = lib.toList
<
{^_^}>
convertToList defined
<
infinisil>
> convertToList 10
<
infinisil>
> convertToList [ 10 ]
<
infinisil>
> 1.5 > 1
<
infinisil>
> 1.5 > 2
<
infinisil>
Hmmm, how could you convert a float to an int..
<
infinisil>
Bisection would work, buuutt
<
infinisil>
> 0.0 == 0
<
infinisil>
> findUpper = value: float: if value >= float then value else findUpper (value * 2) float
<
{^_^}>
findUpper defined
<
infinisil>
> findUpper 1 60.2
<
infinisil>
> findUpper 1 63.999
<
infinisil>
> findUpper 1 64.00
<
infinisil>
> findUpper 1 64.001
<
infinisil>
> bisectFloat = lower: upper: float: if upper - lower <= 1 then lower else let middle = (lower + upper) / 2; in if middle > float then bisectFloat middle upper float else bisectFloat lower middle float
<
{^_^}>
bisectFloat defined
<
infinisil>
> bisectFloat 1 64 52.5
<
infinisil>
> (1 + 64) / 2
<
infinisil>
> bisectFloat = lower: upper: float: if upper - lower <= 1 then lower else let middle = (lower + upper) / 2; in if middle > float then bisectFloat lower middle float else bisectFloat middle upper float
<
{^_^}>
bisectFloat defined
<
infinisil>
> bisectFloat 1 64 52.5
<
infinisil>
> bisectFloat 1 64 64
<
infinisil>
> intToFloatPos = float: bisectFloat 1 (findUpper 1 float) float
<
{^_^}>
intToFloatPos defined
<
infinisil>
> intToFloatPos 54.5
<
infinisil>
> intToFloatPos 1.0
<
infinisil>
> intToFloatPos 1.1
<
infinisil>
> intToFloatPos 1.9
<
infinisil>
> intToFloatPos 2.0
<
infinisil>
> findUpper 1 2.0
<
infinisil>
> bisectFloat = lower: upper: float: if upper - lower <= 1 then upper else let middle = (lower + upper) / 2; in if middle > float then bisectFloat lower middle float else bisectFloat middle upper float
<
{^_^}>
bisectFloat defined
<
infinisil>
> intToFloatPos 2.0
<
infinisil>
> intToFloatPos 1.0
<
infinisil>
> intToFloatPos 1.1.
<
{^_^}>
error: syntax error, unexpected ')', expecting ID or OR_KW or DOLLAR_CURLY or '"', at (string):240:1
<
infinisil>
> intToFloatPos 1.1
<
infinisil>
> intToFloatPos 1.9
<
infinisil>
> intToFloatPos 2.1
<
infinisil>
> bisectFloat = lower: upper: float: if upper - lower <= 1 then lower else let middle = (lower + upper) / 2; in if middle >= float then bisectFloat lower middle float else bisectFloat middle upper float
<
{^_^}>
bisectFloat defined
<
infinisil>
> intToFloatPos 1.1
<
infinisil>
> intToFloatPos 1.9
<
infinisil>
> intToFloatPos 2.0
<
infinisil>
> intToFloatPos 2.1
<
infinisil>
> findUpper = value: float: if value > float then value else findUpper (value * 2) float
<
{^_^}>
findUpper defined
<
infinisil>
> intToFloatPos 2.1
<
infinisil>
> intToFloatPos 2.0
<
infinisil>
> findUpper 2.0
<
infinisil>
> findUpper 1 2.0
<
infinisil>
> (1 + 4) / 2
<
infinisil>
> bisectFloat = lower: upper: float: if upper - lower <= 1 then lower else let middle = (lower + upper) / 2; in if middle > float then bisectFloat lower middle float else bisectFloat middle upper float
<
{^_^}>
bisectFloat defined
<
infinisil>
> intToFloatPos 2.0
<
infinisil>
> intToFloatPos 1.9
<
infinisil>
> intToFloatPos 2.9
<
infinisil>
> intToFloatPos 3.0
<
infinisil>
> intToFloatPos 4.0
<
infinisil>
> intToFloatPos 564.544
<
infinisil>
> intToFloatPos 99999.9
<
infinisil>
> intToFloatPos 1000000
<
infinisil>
Perfect
* samueldr
.oO(nix is not a general purpose programming language)
<
infinisil>
> intToFloat = float: if float <= 1 || float >= -1 then 0 else if float > 0 then intToFloatPos float else -intToFloatPos (-float)
<
{^_^}>
intToFloat defined
<
infinisil>
> intToFloat 0.0
<
infinisil>
> intToFloat 1.0
<
infinisil>
> intToFloat = float: if float < 1 || float > -1 then 0 else if float > 0 then intToFloatPos float else -intToFloatPos (-float)
<
{^_^}>
intToFloat defined
<
infinisil>
samueldr: Yet
<
infinisil>
> intToFloat 1.0
<
infinisil>
> intToFloatPos 1.0
<
infinisil>
> intToFloat = float: if float < 1 && float > -1 then 0 else if float == 1.0if float > 0 then intToFloatPos float else -intToFloatPos (-float)
<
{^_^}>
error: syntax error, unexpected IF, expecting THEN, at (string):101:76
<
infinisil>
> intToFloat = float: if float < 1 && float > -1 then 0 else if float > 0 then intToFloatPos float else -intToFloatPos (-float)
<
{^_^}>
intToFloat defined
<
infinisil>
> intToFloat 1.0
<
infinisil>
> intToFloat 2.0
<
infinisil>
> intToFloat -2.0
<
{^_^}>
value is a function while a float was expected, at (string):240:1
<
infinisil>
> intToFloat (-2.0)
<
infinisil>
> intToFloat (-452.52)
<
infinisil>
> convertToInt = val: { int = val; bool = if val then 1 else 0; string = lib.toInt val; path = lib.toInt val; null = 0; set = lib.length (lib.attrNames val); list = lib.length val; lambda = throw "Can't convert lambda to int"; float = floatToInt val; }.${builtins.typeOf val}
<
{^_^}>
error: undefined variable 'floatToInt' at (string):53:235
<
infinisil>
> floatToInt = float: if float < 1 && float > -1 then 0 else if float > 0 then intToFloatPos float else -intToFloatPos (-float)
<
{^_^}>
floatToInt defined
<
infinisil>
> convertToInt = val: { int = val; bool = if val then 1 else 0; string = lib.toInt val; path = lib.toInt val; null = 0; set = lib.length (lib.attrNames val); list = lib.length val; lambda = throw "Can't convert lambda to int"; float = floatToInt val; }.${builtins.typeOf val}
<
{^_^}>
convertToInt defined
<
infinisil>
> 10.2 + 0
<
infinisil>
> 10.2 + (0 + 0.0)
<
infinisil>
> 10.2 + (0 + 0)
<
infinisil>
> convert = type: { int = convertToInt; bool = convertToBool; string = convertToString; list = convertToList; }.${type} or lib.id
<
{^_^}>
convert defined
<
infinisil>
> convert "int" 10.5
<
infinisil>
> convert "string" 10.5
<
{^_^}>
"10.500000"
<
infinisil>
> convert "list" 10.5
<
infinisil>
> convert "bool" 10.5
<
infinisil>
> let actualAdd = __add; in let __add = x: y: actualAdd (convert "int" x) (convert "int" y); in [ 10 ] + "3.141"
<
{^_^}>
cannot coerce a list to a string, at (string):242:97
<
infinisil>
> let actualAdd = __add; in let __add = x: y: actualAdd (convert "int" x) (convert "int" y); in [ 10 ] + 4.6
<
{^_^}>
cannot coerce a list to a string, at (string):242:97
<
infinisil>
> let actualAdd = __add; in let __add = x: y: actualAdd (convert "int" x) (convert "int" y); in 10 + 4.6
<
infinisil>
> let actualSubtract = __sub; in let __sub = x: y: actualSubtract (convert "int" x) (convert "int" y); in [ 10 ] + "3.141"
<
{^_^}>
cannot coerce a list to a string, at (string):242:107
<
infinisil>
> let actualSubtract = __sub; in let __sub = x: y: actualSubtract (convert "int" x) (convert "int" y); in [ 10 ] - "3.141"
<
{^_^}>
Could not convert 3.141 to int.
<
infinisil>
> let actualSubtract = __sub; in let __sub = x: y: actualSubtract (convert "int" x) (convert "int" y); in [ 10 ] - 3.141
<
infinisil>
OH well whatever I give up
<
infinisil>
Can't do
*that* cool stuff with it
<
infinisil>
And it's a pain lol
__monty__ has quit [Quit: leaving]