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
module IParsec | |
interface Source a where | |
feed : Nat -> a -> (List Char, a) | |
next : a -> (List Char, a) | |
next = feed 1 | |
Source String where | |
feed x string = let (first, second) = splitAt x $ unpack string in | |
(first, pack second) |
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
val l = 1 :: "hello" :: true :: HNil | |
// l: shapeless.::[Int,shapeless.::[String,shapeless.::[Boolean,shapeless.HNil]]] = 1 :: hello :: true :: HNil | |
l.head | |
// res7: Int = 1 | |
l.tail | |
// res8: shapeless.::[String,shapeless.::[Boolean,shapeless.HNil]] = hello :: true :: HNil | |
l(1) |
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
import shapeless._ | |
val hlist1a = HList(1,2,3) | |
val hlist2a = HList(1,"a",3.14) | |
// The above code with type ascription | |
val hlist1b: ::[Int, ::[Int, ::[Int, HNil]]] = HList(1,2,3) | |
val hlist2b: ::[Int, ::[String, ::[Double, HNil]]] = HList(1,"a",3.15) |
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
val list1 : List[Int] = List(1,2,3) // list of integers | |
val list2 : List[String] = List("a","b", "c") // list of strings | |
val list3 : List[Any] = List(1,2,"a","b") // list of any. Here Any is the least upper bound of sting & int |
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
libraryDependencies += "com.chuusai" % "shapeless_2.11" % "2.3.2" |
NewerOlder