This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| f :: x <: Int+[String] -> { | |
| case x of | |
| Int = x | |
| [String] = length x | |
| | x <- x | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data SomeData a b = A a | B b | |
| get :: s <: SomeData a b -> { | |
| case dat of | |
| A a = a | |
| B b = b | |
| | dat <- s | |
| } | |
| x :: Int = get (A 3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| length :: l <: [a] -> { -- This is just a type comprehension spanned over lines, with a full language of syntax | |
| case xxs of | |
| x:xs = 1 + length xs | |
| [] = 0 | |
| | xxs <- l | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data Something a b c = A a | B b | C c | |
| func :: s <: Something a b c - {C _} => s -> Either a b | |
| func s = case s of | |
| A(a) = Left a | |
| B(b) = Right b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| div :: ia <: Int, ib <: Int - {0} => ia -> ib -> { a / b | a <- ia, b <- ib } | |
| div a b = a / b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| div :: n = { i <- Int | i != 0} => Int -> n -> Int | |
| -- or more simply, using set subtraction | |
| div :: n = Int - {0} => Int -> n -> Int | |
| div a b = a / b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| div :: Int -> Int -> Int | |
| div a b = a / b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class StoragePart extends PartBase<PartFactoryPeripherals> implements IWorldNetworkNodeHost, TSlottedPart { | |
| ... | |
| private SinglePeripheralModem modem = new SinglePeripheralModem() { | |
| private final PeripheralOfEnumMethods<StoragePart, ExampleMethods> peripheral = | |
| new PeripheralOfEnumMethods<StoragePart, ExampleMethods>( | |
| StoragePart.this, | |
| ExampleMethods.class, | |
| "exampe_peripheral" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public enum ExampleMethods implements IEnumPeripheralMethods<StoragePart> { | |
| GetPosition("getPosition") { | |
| @Override | |
| public Object[] call(StoragePart data, IComputerAccess iComputerAccess, ILuaContext iLuaContext, Object[] objects) | |
| throws LuaException, InterruptedException { | |
| return new Object[] {data.x(), data.y(), data.z()}; | |
| } | |
| }, | |
| GetDirection("getDirection") { | |
| @Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface IEnumPeripheralMethods<T> { | |
| String getMethodName(); | |
| Object[] call(T data, IComputerAccess iComputerAccess, ILuaContext iLuaContext, Object[] objects) throws LuaException, InterruptedException; | |
| } |