hlist Questions
2
Solved
I have the following Scala problem:
Write a function that will take a list of HLists
List(23 :: “a” :: 1.0d :: HNil, 24 :: “b” :: 2.0d :: HNil) # this is list of hlists
and return back HList of...
2
Solved
Thanks to https://github.com/milessabin/shapeless/wiki/Feature-overview:-shapeless-2.0.0 I understand how to zip shapeless HLists:
Import some stuff from Shapeless 2.0.0-M1:
import shapeless._
im...
1
Solved
How can I pass some HList as an argument? So I can make in a such way:
def HFunc[F, S, T](hlist: F :: S :: T :: HNil) {
// here is some code
}
HFunc(HList(1, true, "String")) // it works perfect...
Hegemony asked 28/10, 2013 at 12:7
1
Solved
Question
Is it somehow possible to create an extractor for shapeless' HList that looks like the following.
val a ~ _ ~ b = 4 :: "so" :: 4.5 :: HNil
=> a == 4 && b == 4.5
Repl...
Aquila asked 27/8, 2013 at 14:42
1
Solved
I'm working on a small library for economic models that check the Units of the entities, using Types, e.g. instead of val apples = 2.0 we write val apples = GoodsAmount[KG, Apples](2.0). For creati...
1
Solved
Suppose we have a following definition of HList:
data HL spec where
HLNil :: HL ()
HLCons :: h -> HL t -> HL (h, t)
Is it possible to somehow enforce a shared constraint on its items?
A...
2
Solved
I'm working on an HList implementation and I'm stuck trying to implement a map function for it. I've tried a lot of different approaches but with each one I reach compiler errors related to that fu...
2
Solved
I have tried
map show . mapMaybe fromDynamic $ [toDyn "one", toDyn (\x -> x::Integer), toDyn 3, toDyn ()]
but it returned
["()"]
Ripping asked 4/2, 2013 at 21:22
1
Solved
I'm using shapeless in Scala, and I'd like to write a function allPairs that will take two HLists and return an HList of all pairs of elements. For example:
import shapeless._
val list1 = 1 :: "on...
1
Solved
With recent posts about HaskellDB, I've been motivated to look into HList again. As we now have -XDataKinds in GHC, which actually has an example of heterogeneous lists, I wanted to investigate how...
1
Solved
I've been trying to use HList to create records.
I've been using the operators defined in HList-GHCSyntax.
It so far works quite nicely, allowing me to write things like this:
myRecord =
(para...
3
Solved
Is it possible to do a foldLeft on a list of arguments, where the initial value supplied to the fold is a fully curried function, the operator is apply, and the list is a list of arguments to be pa...
2
Solved
sealed abstract trait HList
case class :+:[H, T <: HList](head: H, tail: T) extends HList {
def :+:[T](v: T) = new :+:(v, this)
}
case object HNil extends HList {
def :+:[T](v: T) = new :+:(...
© 2022 - 2024 — McMap. All rights reserved.