Coder Social home page Coder Social logo

Comments (3)

pascalpoizat avatar pascalpoizat commented on June 10, 2024

Hello

same issue with a more complex set of pragmas but no QuasiQuote, rather TemplateHaskell (see code below).

I am using https://github.com/haskell/haskell-ide-engine (0.2.1.0) + the https://github.com/alanz/vscode-hie-server plugin for VSC (0.0.21). I work on a stack generated project (using stack new, stack GHCI 8.4.3).

This is how the error comes.

1- type in the code with the TemplateHaskell commented out : OK
2- uncomment it : this error arises
capture d ecran 2018-08-19 a 12 03 21
3- erase the notification : OK
4- make one change in the file (add and remove a space) : GHC Panic
capture d ecran 2018-08-19 a 12 04 11
5- erase the notification and perform any change in the code : GHC panic comes again.

Note: at this step, if I use stack ghci all goes well, the code compiles.

Note: since the error may also partly related to the HIE plugin for VSC, I also filled an issue report here haskell/vscode-haskell#108

code:

{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
--{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE DataKinds #-}
-- some experiments with dependent types / type-level programming in Haskell
-- references:
-- http://www.parsonsmatt.org/2017/04/26/basic_type_level_programming_in_haskell.html
-- https://www.schoolofhaskell.com/user/konn/prove-your-haskell-for-great-safety/dependent-types-in-haskell
-- https://hackage.haskell.org/package/singletons

module Lib
where

import Prelude hiding (head, tail, zipWith)
import Data.Singletons.TH

someFunc :: IO ()
someFunc = putStrLn "Hello, World!"

singletons
   [d|

  data Nat = Z
           | S Nat
               deriving (Show, Eq, Ord)

  (+) :: Nat -> Nat -> Nat
  Z + x = x
  (S n) + x = S (n + x)

  (*) :: Nat -> Nat -> Nat
  Z * x = Z
  (S n) * x = n * x + x

  mymin :: Nat -> Nat -> Nat
  mymin Z Z = Z
  mymin Z (S _) = Z
  mymin (S _) Z = Z
  mymin (S x) (S y) = S (mymin x y)

  |]

data Vector a n where
  Nil :: Vector a Z
  (:-) :: a -> Vector a n -> Vector a (S n)
infixr 5 :-

deriving instance Eq a => Eq (Vector a n)

toList :: Vector a n -> [a]
toList Nil = []
toList (a :- v) = a : toList v

instance Show a => Show (Vector a n) where
  showsPrec p = showsPrec p . toList

append :: Vector a n -> Vector a m -> Vector a (n + m)
append Nil v = v
append (a :- v1) v2 = a :- append v1 v2

head :: Vector a (S n) -> a
head (a :- v) = a

tail :: Vector a (S n) -> a
tail (a :- v) = a

zipWithSame :: (a -> b -> c) -> Vector a n -> Vector b n -> Vector c n
zipWithSame f Nil Nil = Nil
zipWithSame f (a :- v1) (b :- v2) = f a b :- zipWithSame f v1 v2

zipWith :: (a -> b -> c) -> Vector a n -> Vector b m -> Vector c (Mymin n m)
zipWith f Nil Nil = Nil
zipWith f Nil (b :- v) = Nil
zipWith f (a :- v) Nil = Nil
zipWith f (a :- v1) (b :- v2) = f a b :- zipWith f v1 v2

zipSame :: Vector a n -> Vector b n -> Vector (a, b) n
zipSame = zipWithSame (,)

zip :: Vector a n -> Vector b m -> Vector (a, b) (Mymin n m)
zip = zipWith (,)

from ghc-mod.

DanielG avatar DanielG commented on June 10, 2024

Sorry but ghc-mod doesn't even support GHC 8.4 yet, you appear to be using haskell-ide-engine's fork of ghc-mod, please report this on their issue tracker since this is most likely related to code that we don't even have in this repo yet :)

If you can reproduce this issue with plain ghc-mod feel free to reopen, however I should point out that we have a test case for QuasiQuotes support: https://github.com/DanielG/ghc-mod/blob/master/test/CheckSpec.hs#L33.

@alanz could you please update the bugreport url in HIE? It's in https://github.com/DanielG/ghc-mod/blob/master/core/GhcMod/Error.hs#L124

from ghc-mod.

pascalpoizat avatar pascalpoizat commented on June 10, 2024

Hello @DanielG

I downgraded my project from LTS 12.7 (GHC 8.4.3) to LTS 11.17 (GHC 8.2.2).

Now the hie wrapper uses hie-8.2.2 (and the regular ghc-mod inside) instead of hie-8.4.3 (and the hie forked ghc-mod).
All works well. The issue with TemplateHaskell is no longer there.
(please note the I did not made experiments with QuasiQuotes, which was the initial issue by @goekboet )

I will write an issue in HIE then.

Thanks for the solution. I will continue my journey with dependent types in Haskell using GHC 8.2.2.

Best,

Pascal

from ghc-mod.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.