agda / agda2hs

Compiling Agda code to readable Haskell

Home Page:https://agda.github.io/agda2hs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Usage of Sigma adds an incorrect import and forgets brackets

sarajuhosova opened this issue · comments

If we write the following Agda code:

module Sigma where

open import Haskell.Prelude
open import Haskell.Extra.Sigma

sigmaMaybe : Maybe (Σ[ x ∈ String ] Int)
sigmaMaybe = return ("hello" , 1)

{-# COMPILE AGDA2HS sigmaMaybe #-}

sigmaDo : Maybe Int
sigmaDo = do
    _ , i  sigmaMaybe
    return i

{-# COMPILE AGDA2HS sigmaDo #-}

sigmaCase : Σ[ x ∈ a ] b  a
sigmaCase s = case s of λ where (fs , sn)  fs

{-# COMPILE AGDA2HS sigmaCase #-}

This will result in the following incorrect Haskell:

module Sigma where

import Haskell.Extra.Sigma (Σ((,)))

sigmaMaybe :: Maybe (String, Int)
sigmaMaybe = return ("hello", 1)

sigmaDo :: Maybe Int
sigmaDo
  = do _ , i <- sigmaMaybe
       return i

sigmaCase :: (a, b) -> a
sigmaCase s
  = case s of
        fs , sn -> fs
  1. The import Haskell.Extra.Sigma (Σ((,))) shouldn't be there.
  2. The _ , i <- sigmaMaybe is missing brackets around (_ , i)
  3. The fs , sn -> fs is missing brackets around (fs , sn)