Questions tagged [idris]

Idris is a general purpose pure functional programming language with dependent types.

Idris is a general-purpose purely functional programming language with dependent types, strict or optional lazy evaluation and features such as a totality checker.


Useful links:

785 questions
0
votes
0 answers

Long strings mangled for Idris to C++

I'm calling C++ from Idris. It's working fine, mostly, but while I can use short strings fine, long strings get mangled. Here's my code // C++ extern "C" { const char* foo() { std::string res = "foo"; return res.c_str(); …
joel
  • 6,359
  • 2
  • 30
  • 55
0
votes
1 answer

How to crash on internal bug and force totality

I'm ffi-ing to C and the function I call returns an int to mean gt, eq or lt. I want to crash on anything other than 1, 0 or -1 cos that should never happen. And I'd like Idris to consider 0, 1 and -1 to be exhaustive matches. I tried prim__compare…
joel
  • 6,359
  • 2
  • 30
  • 55
0
votes
1 answer

Can't find implementation with constraint in signature

I have an interface that depends on another interface, with some dependent types, and I can't get the compiler to constrain a type in a related function import Data.Vect interface Distribution (0 event : Nat) (dist : Nat -> Nat -> Type) where data…
joel
  • 6,359
  • 2
  • 30
  • 55
0
votes
1 answer

Generic increment function in Idris2

Just learning Idris 2 and trying to implement a generic increment function that could work with any Real/Integer numbers, as far as I know Num type should cover Fractional numbers so I thought that this could satisfy the definition requirements: inc…
allor99
  • 111
  • 3
0
votes
0 answers

Interfaces: parametrise over value or use higher-kindedness?

I'm trying to get my head around the difference between these three interfaces, and when to use each interface Foo (xs : List Nat) (n : Nat) bar where ... interface Foo' (xs : List Nat) (bar : Nat -> Type) where ... interface Foo'' (bar : List…
joel
  • 6,359
  • 2
  • 30
  • 55
0
votes
1 answer

How to transform Haskell type family to Idris type function?

Suppose we have some Haskell type family which maps types to some other types: data (a :: Type) :+: (b :: Type) = a :+: b type family MapType (a :: Type) :: Type type instance MapType Int = Integer type instance MapType Integer = Integer type…
Stefan Dorn
  • 569
  • 2
  • 13
0
votes
0 answers

How to return type that's neither generic or concrete

I have an interface Foo that contains a link to another Foo interface Foo ty where other : ty -> Foo x => x But when I try to implement this data Bar : Type where MkBar : Foo x' => x' -> Bar Foo Bar where other (MkFoo xx) = xx my return…
joel
  • 6,359
  • 2
  • 30
  • 55
0
votes
0 answers

How to write function accepting nested Vect with specific element type?

I want to write a function that accepts arbitrarily-nested Vects whose final elements are of a limited set of types incl. Double and Integer (the "dtype"), and the function is aware of how many Vects there were, and the size of each (i.e. the…
joel
  • 6,359
  • 2
  • 30
  • 55
0
votes
1 answer

INTERNAL ERROR when installing local package

I'm getting Uncaught error: INTERNAL ERROR: Can't make directory foo when trying to install my local library. I'm running idris2 --install foo.ipkg in a directory . +-foo.ipkg +-src +-Util.idr with file contents package foo version =…
joel
  • 6,359
  • 2
  • 30
  • 55
0
votes
1 answer

Idris2: Dependent sum type discrimination

This is probably very basic dependently typed programming problem, but I cannot find anything about it. The problem is this: "I have a bunch of messages that I may or may not have to handle depending on some configuration. How do I discriminate…
Stefan Wullems
  • 743
  • 1
  • 7
  • 20
0
votes
0 answers

Applicative asking for unexpected type

I'm having difficulty implementing Applicative for my type. Here's Functor data Connection : repr -> out -> Type where MkConnection : (repr -> ty) -> (ty -> out) -> Connection repr out Functor (Connection repr) where map f (MkConnection get g)…
joel
  • 6,359
  • 2
  • 30
  • 55
0
votes
1 answer

"Undefined name" for value present in outer scope of where

I want to use a value defined in the outer scope of a where clause, like so foo : Nat foo = case Just 1 of Nothing => 0 Just x => bar where bar : Nat bar = x but I'm getting Error: While processing right hand side of foo. While…
joel
  • 6,359
  • 2
  • 30
  • 55
0
votes
1 answer

Implicit conversions in Idris 2?

Are implicit conversions still available in Idris 2? This Idris 1 code data Foo : Type -> Type where MkFoo : t -> Foo t public export implicit IntFoo : Int -> Foo Int IntFoo = MkFoo now fails to compile in Idris 2 with Error: Parse error at line…
joel
  • 6,359
  • 2
  • 30
  • 55
0
votes
1 answer

Make dependent parameter available in Functor definition

I have the following wrapper for Vect data Foo : (r : Nat) -> (t: Type) -> Type where MkFoo : Vect r t -> Foo r t I'd like to implement Functor for Foo, and use the value of r in the implementation, but I can't get it to compile. Functor (Foo r)…
joel
  • 6,359
  • 2
  • 30
  • 55
0
votes
1 answer

How can I prove a basic inequality in dependant type language

I would like to define the following function in idris, to learn how to deal with negation: absurdity : 0 = 1 -> Void absurdity = ?how How can I do it ? Could I just create an empty lambda and let the compiler figure out that this is not equal ?
rambi
  • 1,013
  • 1
  • 7
  • 25